当前位置:首页
开发技术指南» 文章正文
    引言:
 

 

    摘要: 有谁知道pb中的getsqlpreview()函数怎么调用 ......
    摘要: 请各位指点,最好能提供下载点 ......


有什么方法可以导出表中的记录

我使用的是sqlserver2000,现在希望能够把一个表中的所有记录导出成为一个由多多条insert语句构成的脚本文件,不知有什么好的方法,或工具,谢谢

NO.1   作者: happydreamer

http://expert.csdn.net/Expert/topic/1397/1397315.xml?temp=1.774234E-02  
   
  http://expert.csdn.net/Expert/topic/1374/1374946.xml?temp=.105343

NO.2   作者: psxfghost

多谢   happydreamer(偶很菜)   ,老衲的那种方法很不错,不过如果表字段量太大,生成的sql语句太长会出错的!

NO.3   作者: CrazyFor

老衲的:  
   
  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  
 


    摘要: 我用odbc连接该数据库,进行修复,提示修复完成,但是还是没法打开,下载了accessfix软件,打开该数据库,能看到里面的各个表的内容,但是accessfix是demo版,没有注册是无法修复数据库的!请各位大侠帮帮忙! ......
» 本期热门文章:

©2000-2007 All Rights Reserved. 最佳浏览:1024X768 MSIE