解决方案 »

  1.   

    TO kk19840210
    在存储过程中 中间表怎么建?
    CREATE   proc   out2xls   
      @服务器名   varchar(255),   
      @库名   varchar(255),   
      @表名   varchar(255),   
      @用户名   varchar(100),   
      @密码   varchar(100),   
      @路径及文件名   varchar(255)   
      as   
      declare   @temp1   nvarchar(4000),@temp2   varchar(8000)   
        
      set   @temp1='select   @value1='''',@value2=''''   select   @value1=@value1+'',''''''+''[''+a.name+'']''+char(39),@value2=@value2+'',cast(''+''[''+a.name+'']''+   ''   as   varchar(200))''   from   '+@库名+'..syscolumns   a,'+@库名+'..sysobjects   d   where   a.id=d.id   and   d.name='''+@表名+''''+'   order   by   a.colorder'   
        
      exec   sp_executesql   @temp1,N'@value1   nvarchar(4000)   output   ,   @value2   varchar(8000)   output',@temp1   output,@temp2   output   
        
      select   @temp1=right(@temp1,len(@temp1)-1),@temp2=right(@temp2,len(@temp2)-1)   
        
      select   @temp1+'   union   all   SELECT   '+@temp2+'   into   中间表   FROM   '+@库名+'..'+@表名   
        
      set   @temp2='bcp   '+@库名+'.dbo.中间表   out   '+@路径及文件名+'   -c   -S'+@服务器名+'   -U'+@用户名+'   -P'+@密码   
        
      EXEC   master..xp_cmdshell   @temp2   
      drop   table   中间表   
      GOselect   @temp1+'   union   all   SELECT   '+@temp2+'   into   中间表   FROM   '+@库名+'..'+@表名 这句什么意思?
      

  2.   

    BCP 后边 最大为1024   字节你要不缩短下你的语句