1) DECLARE @tbname sysname,@sql varchar(100)
SET @sql='SELECT '+@tbname+'=name FROM sysobjects where id=1'
EXEC(@sql)
SELECT @tbname
2) declare @num int, @sqls nvarchar(4000)
set @sqls='select @a=count(*) from tableName '
exec sp_executesql @sqls,N'@a int output',@num output
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/3898/viewspace-876186/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/3898/viewspace-876186/