declare @count int
declare @table varchar(50)
set @table = 'webgame_sys_user '
exec( 'SELECT '[email protected]+ ' = COUNT(user_id) FROM '+ @table)
print @count
提示=号附近有语法错误 ?
------解决方案--------------------
declare @count int
declare @table varchar(50)
declare @sql nvarchar(2000)
set @table = 'webgame_sys_user '
set @sql = 'SELECT @count = COUNT(user_id) FROM '+ @table
EXEC sp_executesql @sql,N '@count int output ',@count output
print @count
------解决方案--------------------
declare @count int, @sql Nvarchar(1000)
declare @table varchar(50)
set @table = 'webgame_sys_user '
set @sql = ' SELECT @count = COUNT(user_id) FROM '+ @table
exec sp_executesql @sql, N '@count int output ', @count output
print @count
------解决方案--------------------
declare @count int, @sql nvarchar(4000)
declare @table varchar(50)
set @table = 'webgame_sys_user '
set @sql= 'select @a=count(user_id) from ' + @table
exec sp_executesql @sql,N '@a int output ',@count output
select @count
------解决方案--------------------
用sp_executesql 得到返回参数