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)
改为 declare @cSql Nvarchar(2000) set @cSql= N'Select @RowCount = COUNT(FlowNo) from ' + @DbSource +'..SaleMain ' + @StrQuery
select * from tempdb..sysobjects where [name]='##tempSale'
将 declare @cSql varchar(2000)---------改为declare @cSql nvarchar(2000) = 搞定!!!! 呵呵...好快!!!! if object_id('tempdb..##tempSale') is not null drop table tempdb..##tempSale -- 每次都可以执行成功,但总是提示 忽略了数据库名称 'tempdb',将引用 tempdb 中的对象。 这一句又如何改正啊?????
改正如下:if exists(select * from tempdb.dbo.sysobjects where id = object_id(N'[tempdb].dbo.[##tempSale]')) drop table [dbo].[##tempSale] --如果存在临时表 ##tempSale 则 删除它. OK!给分!!!
drop table tempdb.dbo.##tempSale -----是沒有錯的
但是##tempSale 表 在sql 中存在但是不會 保存在 sysobjects 對象中
2.服务器: 消息 214,级别 16,状态 2,过程 sp_executesql,行 35
过程需要参数 '@statement' 为 'ntext/nchar/nvarchar' 类型。
---------------------------------------------------------------------怎么改正啊?!!!
declare @cSql varchar(2000)---------改为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)
declare @cSql Nvarchar(2000)
set @cSql= N'Select @RowCount = COUNT(FlowNo) from ' + @DbSource +'..SaleMain ' + @StrQuery
if object_id('tempdb..##tempSale') is not null drop table tempdb..##tempSale
-- 每次都可以执行成功,但总是提示 忽略了数据库名称 'tempdb',将引用 tempdb 中的对象。 这一句又如何改正啊?????
drop table [dbo].[##tempSale] --如果存在临时表 ##tempSale 则 删除它. OK!给分!!!