我正在编写一个存储过程,并将表名称作为参数传递,但是我在这里有一个错误部分:SQL Server:Msg 102,Level 15,State 1,Line 2在'='附近的语法不正确
DECLARE
@TableA nvarchar(255)='TableA',
@DOCID1 nvarchar(MAX),
@DOCID2 int;
EXEC ('
SELECT TOP (1) '+ @DOCID1 +'=DOCID1,'+ @DOCID2 +'=DOCID2
FROM [' + @TABLEA + ']
ORDER BY DOCID2')
我运行此查询后,我得到这个错误:
Msg 102, Level 15, State 1, Line 2
Incorrect syntax near '='
我都试过,我不能查明错误,在这一点上我需要一些帮助..
我只是想从select的结果中设置它们的值。 – RicEspn
明白了,感谢您的帮助Marc_s – RicEspn