读书人

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

发布时间: 2012-01-11 22:28:46 作者: rapoo

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

读书人网 >SQL Server

热点推荐