简体   繁体   English

插入语句中的输出子句错误

[英]Error with output clause in insert statement

I'm a little stumped as to why my output clause won't work. 我有点困惑为什么我的输出子句不起作用。 Am I doing something silly? 我在做傻事吗? I keep getting the error, " Incorrect syntax near 'output'." 我不断收到错误消息“输出附近的语法不正确”。

--Create the table to insert into, with identity
create table #testtab(
    businessno int identity(1,1),
    businessname varchar(100), 
    businessref varchar(50), 
    moduser varchar(10), 
    moddate datetime, 
    modtype char(1)
);

--Insert statement with output to capture inserted id numbers
insert into #testtab (businessname, businessref, moduser, moddate, modtype) 
output inserted.businessno,inserted.businessref
values('asd','asd','asd',getdate(),'x');

This is in 2008R2. 这是在2008R2中。

Thanks, Dan 谢谢,丹

Ah.... my bad. 啊...我的坏。 I was actually connected to a SQL 2000 instance from SSMS. 我实际上是从SSMS连接到SQL 2000实例的。 Woops. 哎呀 Doesn't look like 2000 supports output. 看起来不像2000支持输出。 Sigh

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM