亚洲免费在线视频-亚洲啊v-久久免费精品视频-国产精品va-看片地址-成人在线视频网

您的位置:首頁技術文章
文章詳情頁

把SQL SERVER里表里的數據導出成為insert into 腳本

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

--于數據庫里創建如下存儲過程

--使用方式 :proc_insert; ' 要導出的表名'

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

標簽: Sql Server 數據庫
主站蜘蛛池模板: 欧美精品不卡 | 亚洲欧美日韩国产精品26u | 成人亚洲欧美日韩中文字幕 | 亚洲精品在线视频 | 亚洲天堂视频在线观看免费 | 国产精品久久久久久影视 | 欧美色老头oldvideo | 免费国产成人手机在线观看 | 国产初高中生粉嫩无套第一次 | 美女的让男人桶到爽软件 | 国产a级一级久久毛片 | 亚洲人成网站色7799在线观看 | 成人免费毛片视频 | 日韩黄色一级毛片 | 免费播放欧美毛片欧美aaaaa | 一级毛片免费不卡在线 | 成人中文字幕一区二区三区 | 日本一区二区在线 | 页面升级亚洲 | 美女网站在线观看视频18 | 午夜免费的国产片在线观看 | 国产在线观看成人免费视频 | 中文字幕有码视频 | 成人网18免费网站在线 | 国产精品欧美日韩 | 国产一区二区三区高清 | 日本精品一在线观看视频 | 欧美精品久久天天躁 | 在线成人a毛片免费播放 | 亚欧精品在线观看 | 亚洲视频天堂 | 福利片免费一区二区三区 | 一级毛片a免费播放王色 | 欧美jizz18性欧美 | 亚洲毛片免费看 | 亚洲最新视频在线观看 | 成年人视频网站免费 | 成人手机视频在线观看 | 国产一级精品高清一级毛片 | 97在线免费 | 国产成人盗摄精品 |