Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在尝试一些东西,比如在存储过程中。但是,我收到了不正确的错误
select 语句附近的语法。
declare @var int @var=select max(id) from table1 where sname=@'XXX'
试试这个:
declare @var int select @var = max(id) from table1 where sname='XXX'
您缺少 SET 关键字,并且有一个额外的 @ 您不需要。此外,我已将 Select 命令包裹在括号中。
DECLARE @var int SET @var=(SELECT max(id) FROM table1 WHERE sname='XXX')