sql 语句的错误!

       DECLARE @length int --长度
DECLARE @next
int --标量
DECLARE @did
int --地区id
DECLARE @sId1
int

SET @stId
=@@IDENTITY
SET @next
=0
SELECT @length
=COUNT(*) FROM Subject
WHILE(@next
<@length)
BEGIN

SELECT TOP
1 @did=ccId FROM CityCountry
WHERE ccId NOT IN (SELECT TOP @next ccId FROM CityCountry)
INSERT INTO IP_District_Sub_Relation(dId,sId,usrCustomID,usrState,usrRebate)
VALUES(@dId,@sId1,
0,0,0)
 
SET @next
=@next+1
END

消息 102,级别 15,状态 1,过程 MS_InsertIP_Subject,第 71 行'@next' 附近有语法错误。

老提示错误,是怎么回事呢?

ibeautiful
浏览 508回答 1
1回答

月关宝盒

WHERE ccId NOT IN (SELECT TOP (@next) ccId FROM CityCountry)
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

SQL Server