关于网友提出的“ select from table where id=@id和set @count=select count from table不能同时执行”问题疑问,本网通过在网上对“ select from table where id=@id和set @count=select count from table不能同时执行”有关的相关答案进行了整理,供用户进行参考,详细问题解答如下:
问题: select from table where id=@id和set @count=select count from table不能同时执行
描述:create proc test(@id int,@count int output)
as
set @count=(select count(*) from table)
select * from table where id=@id
这样子的话cmd.parameters["@count"].value为null
如果去除select * from table where id=@id output值就正确了
为什么不能同时使用呢?
解决方案1: 可以同时使用,你代码的问题
解决方案2: set @count=(select count(*) from table)
数据集怎么可能给int赋值呢
解决方案3: select @count = count(*) from table
以上介绍了“ select from table where id=@id和set @count=select count from table不能同时执行”的问题解答,希望对有需要的网友有所帮助。
本文网址链接:http://www.codes51.com/itwd/2534695.html