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

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

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

    開花流水

    空山無人,水流花開。

    BlogJava 首頁 新隨筆 聯系 聚合 管理
      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
    執行方法(將tablename替換為相應的數據表名):
    exec proc_insert 'tablename'
    posted on 2010-04-21 13:42 開花流水 閱讀(1224) 評論(0)  編輯  收藏 所屬分類: java
    主站蜘蛛池模板: 欧美最猛性xxxxx免费| 亚洲?V乱码久久精品蜜桃| 免费a级毛片大学生免费观看| 久久亚洲综合色一区二区三区| 亚洲自国产拍揄拍| 久久99精品免费一区二区| 67194熟妇在线永久免费观看 | 亚洲av日韩综合一区二区三区| 免费在线观影网站| 成年女人视频网站免费m| 亚洲级αV无码毛片久久精品| 亚洲欧美成人综合久久久| 国产免费一区二区三区在线观看| 青草草在线视频永久免费| 亚洲国产天堂久久综合网站 | ww亚洲ww在线观看国产| a级成人毛片免费图片| 永久免费毛片手机版在线看| 亚洲AV无码成人专区片在线观看| 狼人大香伊蕉国产WWW亚洲| 久久A级毛片免费观看| 亚洲精品视频在线观看你懂的| 亚洲大尺码专区影院| 中文字幕看片在线a免费| 午夜视频在线在免费| 亚洲精品在线播放| 特级做A爰片毛片免费看无码| 国产精品免费视频一区| 亚洲人成综合在线播放| 久久免费观看国产99精品| 亚洲中文字幕无码爆乳av中文| 亚洲日韩精品无码专区 | 最近中文字幕免费mv在线视频| 国产国拍亚洲精品福利 | 最近中文字幕国语免费完整| 亚洲色中文字幕无码AV| 老外毛片免费视频播放| 毛片在线看免费版| 亚洲成a人片在线观| 日本免费一区二区三区四区五六区 | 伊人婷婷综合缴情亚洲五月|