##tempSale肯定在'tempdb'数据库中的,只是编译时的警告吧

解决方案 »

  1.   

    if   object_id('tempdb.dbo.##tempSale') is not null  
    drop table tempdb.dbo.##tempSale -----是沒有錯的
    但是##tempSale  表  在sql 中存在但是不會 保存在 sysobjects 對象中
      

  2.   

    呵呵,这么快!!主要是这个错误!!!!---------------------------------------------------------------------
    2.服务器: 消息 214,级别 16,状态 2,过程 sp_executesql,行 35
    过程需要参数 '@statement' 为 'ntext/nchar/nvarchar' 类型。
    ---------------------------------------------------------------------怎么改正啊?!!!
      

  3.   


    declare  @cSql varchar(2000)---------改为declare  @cSql nvarchar(2000)
      

  4.   

    declare  @cSql nvarchar(2000)
    declare @RowCount int 
    if   object_id('tempdb..##tempSale') is not null  drop table tempdb..##tempSale --有错!!! set  @cSql= 'Select @RowCount = COUNT(FlowNo) from '  +   @DbSource +'..SaleMain ' + @StrQuery   
    exec sp_executesql @cSql ,N'@RowCount int output',@RowCount  OUT
    select @RowCount = CAST( @SelectPercent * @RowCount as int)
      

  5.   

    改为
    declare  @cSql Nvarchar(2000)
    set  @cSql= N'Select @RowCount = COUNT(FlowNo) from '  +   @DbSource +'..SaleMain ' + @StrQuery   
      

  6.   

    select * from tempdb..sysobjects where [name]='##tempSale'
      

  7.   

    将 declare  @cSql varchar(2000)---------改为declare  @cSql nvarchar(2000)    =   搞定!!!! 呵呵...好快!!!!
    if   object_id('tempdb..##tempSale') is not null  drop table tempdb..##tempSale 
    -- 每次都可以执行成功,但总是提示    忽略了数据库名称 'tempdb',将引用 tempdb 中的对象。 这一句又如何改正啊?????
      

  8.   

    改正如下:if exists(select * from tempdb.dbo.sysobjects where id = object_id(N'[tempdb].dbo.[##tempSale]')) 
    drop table [dbo].[##tempSale] --如果存在临时表 ##tempSale  则 删除它. OK!给分!!!