注册 登录
编程论坛 SQL Server论坛

求救啊

copy462829 发布于 2007-11-26 18:40, 647 次点击
exec(' select [email=]'+@RecordCount+'=isnull(count(*),0[/email]) as abc from tb_User as a  '+ @str+'  ')
第 1 行: '=' 附近有语法错误。

请问该怎么修改过来  谢谢了
6 回复
#2
copy4628292007-11-26 18:41
exec(' select  '+@RecordCount+' =isnull(count(*),0) as abc from tb_User as a  '+ @str+'  ')

自己顶
#3
purana2007-11-26 18:46
declare @ReCount int
declare @sql nvarchar(4000)
set @sql=N' select  '+@RecordCount+' =isnull(count(*),0) as abc from tb_User as a  '+ @str+'  '
exec sp_executesql @sql,N'@RecordCount int output',@ReCount int output

这样呢?
#4
copy4628292007-11-26 20:16
还是不行
'int' 附近有语法错误。
#5
copy4628292007-11-26 20:16
麻烦了你 版主
#6
purana2007-11-26 20:36
这样子呢?.

declare @ReCount int
declare @sql nvarchar(4000)
set @sql=N' select  '+@RecordCount+' =isnull(count(*),0) as abc from tb_User as a  '+ @str
exec sp_executesql @sql,N'@RecordCount int output',@ReCount output
#7
copy4628292007-11-26 21:39
declare @strsql Nvarchar(1000)

Select @strsql=N'select @RecordCount=isnull(count(*),0) from tb_User  ' +@str+' '
exec sp_executesql @strsql,N'@RecordCount bigint output',@RecordCount output

Select @RecordCount

这样的 解决了  谢谢你了版主 通过这交流 又懂了多一点 谢谢你
1