mssql出错:A SELECT statement that assigns a value to a variable must not be combined with data-retrieval operations.

来源:互联网 发布:乐视网络电视下载安卓 编辑:程序博客网 时间:2024/05/29 13:42

今天执行下列语句的时候报错,在网上找了半天也没找到原因。最后还是自己找到原因了。

 

Declare @START_STATUS varchar(200)
Declare @FINISH_STATUS varchar(200)

  select top 1 @START_STATUS=sws.name,@FINISH_STATUS=fws.name fcc.time_type from
  projectcenter.time_field_calculate_config fcc inner join projectcenter.workflow_status sws on
  fcc.start_status_id= sws.id inner join projectcenter.workflow_status fws on fcc.finish_status_id= fws.id
   where project_group_id=@proj_group_id and auser_id=@user_id

 

Msg 141, Level 15, State 1, Line 18
A SELECT statement that assigns a value to a variable must not be combined with data-retrieval operations.

 

看这句语句大家就明白了吧。就这样解决了

 

Declare @FIRST_DATE datetime
Declare @SECOND_DATE datetime
Declare @START_STATUS varchar(200)
Declare @FINISH_STATUS varchar(200)
Declare @TIME_TYPE varchar(200)

 

  select top 1 @START_STATUS=sws.name,@FINISH_STATUS=fws.name,@TIME_TYPE=fcc.time_type from
  projectcenter.time_field_calculate_config fcc inner join projectcenter.workflow_status sws on
  fcc.start_status_id= sws.id inner join projectcenter.workflow_status fws on fcc.finish_status_id= fws.id
   where project_group_id=@proj_group_id and auser_id=@user_id