<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    開花流水

    空山無人,水流花開。

    BlogJava 首頁 新隨筆 聯(lián)系 聚合 管理
      79 Posts :: 42 Stories :: 160 Comments :: 0 Trackbacks
    declare @objectId int
    set @objectId=object_id('proc_insert')
    if @objectId is not null
    begin
        drop proc proc_insert
    end
    go

    create proc proc_insert (@tablename varchar(256))
    as
    begin
        set nocount on
        declare @sqlstr varchar(4000)
        declare @sqlstr1 varchar(4000)
        declare @sqlstr2 varchar(4000)
        select @sqlstr='select ''insert '+@tablename
        select @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.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
    go
    執(zhí)行方法(將tablename替換為相應(yīng)的數(shù)據(jù)表名):
    exec proc_insert 'tablename'
    posted on 2010-04-21 13:42 開花流水 閱讀(1224) 評論(0)  編輯  收藏 所屬分類: java
    主站蜘蛛池模板: 久久国产免费一区| 亚洲国产精品嫩草影院| 久青草视频在线观看免费| 免费v片视频在线观看视频| 国产成人高清亚洲一区久久| 日韩免费福利视频| 亚洲s码欧洲m码吹潮| 免费人妻无码不卡中文字幕18禁| 亚洲成a∨人片在无码2023| 免费无码不卡视频在线观看| 亚洲aⅴ无码专区在线观看春色| 免费国产a国产片高清| 免费夜色污私人影院网站| 亚洲性日韩精品国产一区二区| 国产精品永久免费视频| 久久精品国产亚洲沈樵| 国产白丝无码免费视频| 亚洲乱码卡三乱码新区| 免费看大美女大黄大色| 男女猛烈无遮掩视频免费软件| 在线亚洲人成电影网站色www| 波多野结衣免费一区视频| 亚洲精品综合久久中文字幕| 99热在线精品免费全部my| 国产午夜亚洲精品不卡| 国产精品亚洲аv无码播放| 久久99国产综合精品免费| 男人天堂2018亚洲男人天堂| 日本免费一区尤物| 国产精品黄页免费高清在线观看| 亚洲AV午夜成人影院老师机影院| 久久综合AV免费观看| 国产精品永久免费| 亚洲人成人77777网站不卡| 亚洲第一区精品日韩在线播放| 免费人成毛片动漫在线播放| 亚洲综合国产成人丁香五月激情 | 美女无遮挡免费视频网站| 狠狠色婷婷狠狠狠亚洲综合| 最近中文字幕国语免费完整 | 亚洲 日韩经典 中文字幕 |