亚洲精品久久久中文字幕-亚洲精品久久片久久-亚洲精品久久青草-亚洲精品久久婷婷爱久久婷婷-亚洲精品久久午夜香蕉

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

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

瀏覽:117日期: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 數據庫
主站蜘蛛池模板: 六月丁香婷婷色狠狠久久 | 一区 在线播放 | 日韩欧美一区二区三区不卡视频 | 色婷婷色| 国产午夜精品久久久久九九 | 青草视频在线观看免费资源 | 亚洲国产成人久久综合区 | 成人网免费看 | 欧美日韩精彩视频 | 欧美国产日本 | 99re在线 | 亚洲第一页国产 | 91亚洲人成手机在线观看 | 日韩视频 中文字幕 | 免费中文字幕视频 | 久久免费毛片 | 麻豆91av| 亚洲精品一区二区三区四区手机版 | 色综合小说久久综合图片 | 黄色片免费在线看 | 4388x17亚洲最大成人网 | 久热青青青在线视频精品 | 影音先锋5566av资源网 | 亚洲欧美另类自拍第一页 | 婷婷婷色| 在线亚洲综合 | 免费视频二区 | 亚洲欧美在线精品 | 日本一级毛片视频在线看 | 中文字幕伊人久久网 | 色综合a | 一区二区三区四区在线观看视频 | 亚洲国语在线视频手机在线 | 国产1区2区在线观看 | 国产在线a不卡免费视频 | 韩国一级黄色录像 | 国产亚洲欧美一区二区三区 | 亚洲国产精品人久久 | 干成人| 国产色影院 | 亚洲精品国产成人7777 |