日期:2014-05-18  浏览次数:20695 次

这句是哪里错了,找不到原因啊?
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