SQL error

Category: MS-SQL Server -> Applications Author: huojianbing00000 Date: 2001-07-08 23:11:56
 
huojianbing00000
2001-07-08 23:11:56

declare @ empid int
select top 1 empid into @ empid from peremployee where empid = 1620

error message:
Line 2: Incorrect syntax near '@ empid'.
n12790
2001-07-08 23:30:49
select @ empid = top 1 empid from peremployee where empid = 1620
rdcdape
2001-07-09 00:06:20
select * into statements that are inserted into the table variable
@ empid is not the table
gongquancheng
2001-07-09 00:24:38
declare @ empid int
set @ empid = 0
if (select top 1 @ empid = empid from peremployee where empid = 1620)> 0
begin
select @ empid
end
error code:
Server: Msg 170, Level 15, State 1, Line 4
Line 4: Incorrect syntax near '='.

declare @ empid int
set @ empid = 0
select top 1 @ empid = empid from peremployee where empid = 1620
select @ empid
Results: 1620

at how to change before they can do ?
gxl122333
2001-07-09 00:45:48
....
mssql does not support this into variable ....

declare @ empid int;
set @ empid = (select top 1 empid from peremployee where empid = 1620);
banddylu
2001-07-09 01:20:39
declare @ empid int
set @ empid = 0
if (select top 1 @ empid = empid from peremployee where empid = 1620)> 0
begin
select @ empid
end

into
declare @ empid int;
set @ empid = (select top 1 empid from peremployee where empid = 1620) ;
if (@ empid> 0)
begin
select @ empid
end
superdinger
2001-07-09 01:48:45
5 floor has been given the answer ; lz you try
qaz706366202
2001-07-09 02:19:33
declare @ empid int
select top 1 @ empid = empid from peremployee where empid = 1620
select @ empid