您现在的位置:速学网教学教育考试频道计算机考试计算机等级考试试题如何为SQLServer表数据生成insert脚本(1)» 正文

如何为SQLServer表数据生成insert脚本(1)

[01-23 15:40:22]   来源:http://www.suxue6.com  计算机等级考试试题   阅读:8301

概要: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+','''''''','''''''''...
如何为SQLServer表数据生成insert脚本(1),标签:全国计算机等级考试试题,全国计算机等级考试一级试题,http://www.suxue6.com
  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.name
  from 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 colid
  select @sqlstr=@sqlstr+left(@sqlstr2,len(@sqlstr2)-1)+') '+left(@sqlstr1,len(@sqlstr1)-3)+')'' from '+@tablename
  -- print @sqlstr
  exec( @sqlstr)
  set nocount off
  end

上一页  [1] [2] 


Tag:计算机等级考试试题全国计算机等级考试试题,全国计算机等级考试一级试题考试频道 - 计算机考试 - 计算机等级考试试题
《如何为SQLServer表数据生成insert脚本(1)》相关文章

Copyright 速学网 © 版权所有 All Rights Reserved.

1 2 3 4 5 6