sql 语句错误,请大哥大姐们帮忙看一下

wubaowang 2008-06-18 02:21:17
DECLARE @name varchar(50)
DECLARE @smsCount int
DECLARE @DataString datetime
DECLARE @s nvarchar(200)

set @DataString = getdate()-3
set @name='资料40000'

if EXISTS(select TABLE_Name from information_schema.tables where TABLE_Name='temp')
begin
drop table temp
end
set @s='SELECT * into temp FROM '+ @name +' where datediff(d,'''+ cast(@DataString as nvarchar(25))+''',日期)=0'
exec(@s)
-- print @s
--select * from temp

set @smsCount=(select * from temp)

print @smsCount



--------------------------------------------

错误提示
消息 116,级别 16,状态 1,第 23 行
Only one expression can be specified in the select list when the subquery is not introduced with EXISTS.
...全文
140 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
liangCK 2008-06-18
  • 打赏
  • 举报
回复
[Quote=引用 4 楼 charry0110 的回复:]
同一小虫
set @smsCount=(select * from temp)

将seleclt 的多个值给变量@smsCount不允许
[/Quote]
nzperfect 2008-06-18
  • 打赏
  • 举报
回复
set @smsCount=(select * from temp)

-->

select @smsCount=count(*) from temp
wzy_love_sly 2008-06-18
  • 打赏
  • 举报
回复
select @smsCount=count(*) from temp
晓风残月0110 2008-06-18
  • 打赏
  • 举报
回复
同一小虫
set @smsCount=(select * from temp)

将seleclt 的多个值给变量@smsCount不允许
fcuandy 2008-06-18
  • 打赏
  • 举报
回复
是这个地方错了,至于怎么改要看楼主希望@smscount能得到什么了。估计可能像楼上那样。
-狙击手- 2008-06-18
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 kk19840210 的回复:]
set @smsCount=(select * from temp)


这地方错了


set @smsCount=(select count(*) from temp)

试下
[/Quote]
kk19840210 2008-06-18
  • 打赏
  • 举报
回复
set @smsCount=(select * from temp)



这地方错了


set @smsCount=(select count(*) from temp)

试下

27,579

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server 应用实例
社区管理员
  • 应用实例社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧