国产成人精品久久免费动漫-国产成人精品天堂-国产成人精品区在线观看-国产成人精品日本-a级毛片无码免费真人-a级毛片毛片免费观看久潮喷

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

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

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

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

--使用方式 :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

主站蜘蛛池模板: 日韩精品中文字幕视频一区 | 亚洲国产精品激情在线观看 | 大片毛片 | 成人爽a毛片在线视频 | 最新69成人精品毛片 | 黄色毛片在线 | 91九色精品国产免费 | 国产成人在线影院 | 亚洲成aⅴ人片在线观 | 视频一区色眯眯视频在线 | 欧美怡红院高清在线 | 午夜精品久久久久久91 | 免费看一毛一级毛片视频 | 国产三级日产三级日本三级 | 欧美日韩一级片在线观看 | 颜值超高的女神啪啪 | 国内高清自拍 | 久草免费公开视频 | aaaa级毛片 | 三级视频在线 | 91精品国产免费 | 欧美18www| 国产欧美一区二区三区视频 | 国产亚洲精品一区久久 | 男人在线天堂 | 国产不卡在线观看视频 | 日本b站一卡二不卡 | 精品成人久久 | 三区在线视频 | 乱子伦一级在线现看 | 一级在线视频 | 日韩国产成人资源精品视频 | 国产精品国色综合久久 | 国产在线综合视频 | 91香蕉成人免费高清网站 | 国产成人在线视频 | 亚洲成aⅴ人片在线观 | 亚洲视频男人的天堂 | 性感美女一级毛片 | 天天看片天天爽_免费播放 天天看夜夜 | 久久精品亚洲一级毛片 |