向变量赋值的“SELECT”语句能不能与数据检索操作结合使用?
1个回答
展开全部
错误是因为检索的数据列没有全部赋值给变量
1、可以去掉count(RtID)来解决
select top 1 @RtID = RtID from bbsReply
2、可以多加一个变量保存count(RtID)
declare @RtID int, @cRtID int
select top 1 @RtID = RtID , @cRtID = count(RtID) from bbsReply group by RtID
3、如果你想保存RtID并检索数据,就只能分两步走了
select top 1 @RtID = RtID from bbsReply
select top 1 RtID , count(RtID) from bbsReply group by RtID
1、可以去掉count(RtID)来解决
select top 1 @RtID = RtID from bbsReply
2、可以多加一个变量保存count(RtID)
declare @RtID int, @cRtID int
select top 1 @RtID = RtID , @cRtID = count(RtID) from bbsReply group by RtID
3、如果你想保存RtID并检索数据,就只能分两步走了
select top 1 @RtID = RtID from bbsReply
select top 1 RtID , count(RtID) from bbsReply group by RtID
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询