久久福利_99r_国产日韩在线视频_直接看av的网站_中文欧美日韩_久久一

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

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

瀏覽:126日期: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 數據庫
主站蜘蛛池模板: 黄色国产视频 | 精品国产乱码久久久久久久软件 | 国产激情在线观看视频 | 日本亚洲国产一区二区三区 | 黄色片网站在线看 | 精品视频免费在线 | 国产成人高清视频 | 成人日韩| 91精品国产高清一区二区三区 | 久久99精品久久久久子伦 | 欧美精品第一页 | 国外成人在线视频 | 亚洲视频精品在线 | 在线观看亚洲 | 亚洲三级在线播放 | 四虎av| 久久免费电影 | 国产精品白浆 | 亚洲精品一区二区三区麻豆 | 日本一区二区三区免费观看 | 欧美精品一区自拍a毛片在线视频 | 精品少妇一区二区三区在线播放 | 亚洲欧洲av在线 | 日韩在线看片 | 亚洲国产精品久久人人爱 | 国产v片| 国产午夜精品久久久久久久 | 欧美精品成人一区二区三区四区 | 在线激情视频 | 成人免费毛片aaaaaa片 | 国产精品国产精品国产专区不蜜 | 欧美国产在线视频 | 精品一级 | 国产一区二区三区在线看 | 欧美亚洲免费 | 国产精品免费看 | 在线观看亚洲视频 | 久久伊人青青草 | 狠狠搞狠狠搞 | 国产福利一区二区三区四区 | 黄色在线免费 |