av一区二区在线观看_亚洲男人的天堂网站_日韩亚洲视频_在线成人免费_欧美日韩精品免费观看视频_久草视

您的位置:首頁技術(shù)文章
文章詳情頁

把SQL SERVER里表里的數(shù)據(jù)導(dǎo)出成為insert into 腳本

瀏覽:150日期:2023-11-01 17:18:37

--于數(shù)據(jù)庫(kù)里創(chuàng)建如下存儲(chǔ)過程

--使用方式 :proc_insert; ' 要導(dǎo)出的表名'

create proc proc_insert (@tablename varchar(256))asbeginset nocount ondeclare @sqlstr varchar(4000)declare @sqlstr1 varchar(4000)declare @sqlstr2 varchar(4000)select @sqlstr='select ''insert '+@tablenameselect @sqlstr1=''select @sqlstr2=' ('select @sqlstr1= ' values ( ''+'select @sqlstr1=@sqlstr1+col+'+'',''+' ,@sqlstr2=@sqlstr2+name +',' from (select case -- when a.xtype =173 then 'case when '+a.name+' is null then ''NULL'' else '+'convert(varchar('+convert(varchar(4),a.length*2+2)+'),'+a.name +')'+' end'when a.xtype =104 then 'case when '+a.name+' is null then ''NULL'' else '+'convert(varchar(1),'+a.name +')'+' end'when a.xtype =175 then 'case when '+a.name+' is null then ''NULL'' else '+'''''''''+'+'replace('+a.name+','''''''','''''''''''')' + '+'''''''''+' end'when a.xtype =61; then 'case when '+a.name+' is null then ''NULL'' else '+'''''''''+'+'convert(varchar(23),'+a.name +',121)'+ '+'''''''''+' end'when a.xtype =106 then 'case when '+a.name+' is null then ''NULL'' else '+'convert(varchar('+convert(varchar(4),a.xprec+2)+'),'+a.name +')'+' end'when a.xtype =62; then 'case when '+a.name+' is null then ''NULL'' else '+'convert(varchar(23),'+a.name +',2)'+' end'when a.xtype =56; then 'case when '+a.name+' is null then ''NULL'' else '+'convert(varchar(11),'+a.name +')'+' end'when a.xtype =60; then 'case when '+a.name+' is null then ''NULL'' else '+'convert(varchar(22),'+a.name +')'+' end'when a.xtype =239 then 'case when '+a.name+' is null then ''NULL'' else '+'''''''''+'+'replace('+a.name+','''''''','''''''''''')' + '+'''''''''+' end'when a.xtype =108 then 'case when '+a.name+' is null then ''NULL'' else '+'convert(varchar('+convert(varchar(4),a.xprec+2)+'),'+a.name +')'+' end'when a.xtype =231 then 'case when '+a.name+' is null then ''NULL'' else '+'''''''''+'+'replace('+a.name+','''''''','''''''''''')' + '+'''''''''+' end'when a.xtype =59; then 'case when '+a.name+' is null then ''NULL'' else '+'convert(varchar(23),'+a.name +',2)'+' end'when a.xtype =58; then 'case when '+a.name+' is null then ''NULL'' else '+'''''''''+'+'convert(varchar(23),'+a.name +',121)'+ '+'''''''''+' end'when a.xtype =52; then 'case when '+a.name+' is null then ''NULL'' else '+'convert(varchar(12),'+a.name +')'+' end'when a.xtype =122 then 'case when '+a.name+' is null then ''NULL'' else '+'convert(varchar(22),'+a.name +')'+' end'when a.xtype =48; then 'case when '+a.name+' is null then ''NULL'' else '+'convert(varchar(6),'+a.name +')'+' end'-- when a.xtype =165 then 'case when '+a.name+' is null then ''NULL'' else '+'convert(varchar('+convert(varchar(4),a.length*2+2)+'),'+a.name +')'+' end'when a.xtype =167 then 'case when '+a.name+' is null then ''NULL'' else '+'''''''''+'+'replace('+a.name+','''''''','''''''''''')' + '+'''''''''+' end'else '''NULL'''end as col,a.colid,a.namefrom syscolumns a where a.id = object_id(@tablename) and a.xtype <>189 and a.xtype <>34 and a.xtype <>35 and; a.xtype <>36)t order by colidselect @sqlstr=@sqlstr+left(@sqlstr2,len(@sqlstr2)-1)+') '+left(@sqlstr1,len(@sqlstr1)-3)+')'' from '+@tablename print @sqlstr--exec( @sqlstr)set nocount offendgo

主站蜘蛛池模板: 黄色日批视频 | 日韩综合在线观看 | 欧美日韩在线精品 | 日韩欧美在线播放 | 国产欧美精品一区二区 | av小说在线观看 | 日韩久久久 | 一区二区三区日韩 | 国产精品久免费的黄网站 | 国产精品主播一区二区 | 日韩精品一区在线 | 欧美日韩国产成人 | 极品av在线 | 快播少女爱欢乐 | 日韩精品毛片 | 国产精品一区二区三区免费 | 人人草人人 | 视频在线观看一区 | 欧美色偷偷 | 精品欧美日韩 | 国产黄色片在线观看 | 瑟瑟视频在线观看 | 91激情网 | 日韩一区二区在线播放 | 成年人视频在线播放 | 黄色一级片免费看 | 国产福利在线播放 | 欧美激情综合五月色丁香 | 成年人免费在线观看 | 亚洲黄色在线 | 亚洲欧美一区二区三区四区 | 欧美成人精品激情在线观看 | 欧美精品成人 | 亚洲视频在线观看免费 | 久久久www成人免费精品 | 色午夜| 秋霞一区二区 | 亚洲欧美在线播放 | 午夜网站在线观看 | 中文字幕手机在线观看 | 亚洲三级黄色片 |