澳门京葡网站信任函数,导出数据脚本

GenUpdate Table Name,SQL Server编写存储过程小工具 功能,if @objectId is null — 判斷對象是否存在,1 —

select @MaxCol = max(colorder) from syscolumns where id = @TableID

print ‘The object is not table’

  • @PrimaryKey + = @ + @PrimaryKey,(2 * @maxcol) + 4 as colorder order
    by colorder

declare @sql varchar(4000)

drop table #tempproc /*=======源程序甘休=========*/

select @ident=status&0x80 from syscolumns where id=@objectid and
status&0x80=0x80

SQL Server编写存储进度小工具 作用:为给定表创立Update存款和储蓄进度 语法:
sp_GenUpdate Table Name,Primary Key,Stored Procedure Name 以northwind
数据库为例 sp_GenUpdate Employees,EmployeeID,UPD_Employees

declare @name sysname

===========================================================*/ CREATE
procedure sp_GenUpdate @TableName varchar(130), @PrimaryKey
varchar(130), @ProcedureName varchar(130) as set nocount on

begin if @@fetch_status < >-2

基本提醒:SQL
Server编写存款和储蓄进程小工具功用:为给定表创造Update存款和储蓄进程

fetch next from syscolumns_cursor into @name,@xtype

select Create Procedure + rtrim(@ProcedureName) as type,0 as colorder
into #TempProc union select convert(char(35),@ + syscolumns.name) +
rtrim(systypes.name) + case when rtrim(systypes.name) in
(binary,char,nchar,nvarchar,varbinary,varchar) then ( +
rtrim(convert(char(4),syscolumns.length)) + ) when rtrim(systypes.name)
not in (binary,char,nchar,nvarchar,varbinary,varchar) then end + case
when colorder @maxcol then , when colorder = @maxcol then end as type,
colorder from syscolumns join systypes on syscolumns.xtype =
systypes.xtype where id = @TableID and systypes.name sysname union
select AS,@maxcol + 1 as colorder union select UPDATE +
@TableName,@maxcol + 2 as colorder union select SET,@maxcol + 3 as
colorder union select syscolumns.name + = @ + syscolumns.name + case
when colorder @maxcol then , when colorder = @maxcol then end as type,
colorder + @maxcol + 3 as colorder from syscolumns join systypes on
syscolumns.xtype = systypes.xtype where id = @TableID and
syscolumns.name @PrimaryKey and systypes.name sysname union select WHERE

begin
set @column=@column+case when len(@column)=0 then” else ‘,’end+@name
set @columndata=@columndata+case when len(@columndata)=0 then ” else
‘,”,”,’ end
+case when @xtype in(167,175) then ””””’+’+@name+’+””””’
–varchar,char

declare @maxcol int, @TableID int knowsky.com set @TableID =
object_id(@TableName)

end

批注:如若你在Master系统数据库中创制该进程,那您就能够在你服务器上有所的数据库中应用该进度。

if @ident is not null print ‘SET IDENTITY_INSERT ‘+@TableName+’ ON’

select type from #tempproc order by colorder

return

ALTER PROCEDURE [dbo].[UspOutputData]

澳门京葡网站,set @sql=’set nocount on select ”insert ‘+@tablename+'(‘+@column+’)
values(”as ”–”,’+@columndata+’,”)” from ‘+@tablename

print ‘The object not exists’

declare @objectname sysname

declare @column varchar(2000)

begin

declare @columndata varchar(2000)

end

for select c.name,c.xtype from syscolumns c where c.id=@objectid order
by c.colid

USE [XXX] GO

AS

set @objectname=rtrim(object_name(@objectId))

close syscolumns_cursor deallocate syscolumns_cursor

if @ident is not null print ‘SET IDENTITY_INSERT ‘+@TableName+’ OFF’

return

while @@fetch_status < >-1