sql脚本生成器:将表数据生成SQL脚本的存储过程来源: 发布时间:星期六, 2009年2月7日 浏览:0次 评论:0
="t18">作者:zlt982001
将表数据生成SQL脚本 ![]() CREATE PROCEDURE dbo.UspOutputData @tablename sysname AS declare @column varchar(1000) declare @columndata varchar(1000) declare @sql varchar(4000) declare @xtype tiny ![]() declare @name sysname declare @objectId ![]() declare @objectname sysname declare @ident ![]() ![]() ![]() begin pr ![]() ![]() end ![]() ![]() begin pr ![]() ![]() end ![]() begin pr ![]() ![]() end select @ident=status&0x80 from syscolumns where id=@objectid and status&0x80=0x80 ![]() pr ![]() open syscolumns_cursor ![]() ![]() fetch next from syscolumns_cursor ![]() while @@fetch_status < >-1 begin ![]() begin ![]() ![]() begin ![]() ![]() ![]() ![]() ![]() ![]() end + ![]() when @xtype in(231,239) then '''N''''''+'+@name+'+''''''''' --nvarchar,nchar when @xtype=61 then '''''''''+convert(char(23),'+@name+',121)+''''''''' --datetime when @xtype=58 then '''''''''+convert(char(16),'+@name+',120)+''''''''' --smalldatetime when @xtype=36 then '''''''''+convert(char(36),'+@name+')+''''''''' --uniqueident ![]() ![]() end end fetch next from syscolumns_cursor ![]() end close syscolumns_cursor deallocate syscolumns_cursor ![]() ![]() pr ![]() exec(@sql) ![]() pr ![]() GO exec UspOutputData 你 ![]() 0
相关文章读者评论发表评论 |
|