declare @str Nvarchar(1000)
set @str=N'select @count=count(*) from '+@table
exec sp_executesql @str,N' @Count int output',@Count outputif @count>0
return (1)
else
return (0)
set @str=N'select @count=count(*) from '+@table
exec sp_executesql @str,N' @Count int output',@Count outputif @count>0
return (1)
else
return (0)
解决方案 »
- sql2000数据要 移到 服务器上的数据库
- 执行速度问题。新手请教
- 如何写这句删除的sql语句
- select* from between date1 and date2 请教?
- 求一个汇总的SQL语句
- MSSQL2000脚本删除数据
- 如何实现不同批次的物料只用一张单据?
- 问个问题,找了很久都没有答案?
- 存储过程单引号问题
- 微软的 sql 2000 的查询分析器 可以非常快速的接受并显示 几十万行的结果集DimensionDataCtrl控件
- 求 sqlserver 中类似于 oracle 的 decode 函数
- Vfp数据库非正常退出时造成索引被破坏和数据表结构的破坏,造成数据丢失,有何解决办法?
EXEC sp_executesql @str ,N'@count int output',@count outputif @count > 0
return 1
else
return 0
@str='select '+@count+'=count(*)from '+@table
exec (@str) 要出错的动态执行sql 还是用sp_executesql
select @a = 'declare @aa int
select @aa = count(*) from treeclass
print (@aa)'
exec(@a)EXEC sp_executesql @str ,N'@count int output',@count output