当前位置: 代码迷 >> Sql Server >> 这句是错哪了,找不到原因啊
  详细解决方案

这句是错哪了,找不到原因啊

热度:90   发布时间:2016-04-27 19:44:15.0
这句是哪里错了,找不到原因啊?
declare   @employeesInt   int;
set   @employeesInt=select   count(*)   from   employees   where   month(birthdate)=month(getdate());

总是报错如下:
消息   156,级别   15,状态   1,第   2   行
关键字   'select '   附近有语法错误。

高手指点。

------解决方案--------------------
declare @employeesInt int;
select @employeesInt=count(*) from employees where month(birthdate)=month(getdate());
------解决方案--------------------
declare @employeesInt int;
set @employeesInt=(select count(*) from employees where month(birthdate)=month(getdate()));
------解决方案--------------------
支持yesyesyes的 可以用set 但赋值时要把语句括起来
declare @employeesInt int;
set @employeesInt=(select count(*) from employees where month(birthdate)=month(getdate()));
print @employeesInt
  相关解决方案