English 中文(简体)
表格变量中的不正确的语法
原标题:Incorrect syntax in table variable insert via select
  • 时间:2012-05-27 15:15:42
  •  标签:
  • t-sql

我不知道这世界上在抱怨什么 在我看来很好

DECLARE @newidentity int 
SET @newidentity = scope_identity()
select @newidentity

Insert into @Companies (select @newidentity, Name from Company where Name =  Parker )

插入一行,我得到以下内容:

Incorrect syntax near the keyword select .
Incorrect syntax near ) .

最佳回答

请尝试删除括号并指定公司的字段,请:

INSERT INTO @Companies 
            (field1, 
             field2) 
SELECT @newidentity, 
       Name 
FROM   Company 
WHERE  Name =  Parker  

什么是“code” companyes ?

问题回答

暂无回答




相关问题
两个表格的精度

我正试图加入在服务器上的多个桌子,并保持快速业绩。

SELECT last row if USER is found

I have a log table in SQL Server. Table is structured this way: Unique ProblemID ResponsibleID AssignedToID ProblemCode 155 155 0282 4 156 155 ...

How to convert a Tsql scalar function into a table function?

I am using SSMS 2008 and I have the following scalar function to take a text string and remove all metatags from Microsoft Word. The tags are enclosed in "<...>" and there can be any number of ...

Interesting SQL query

I have this data in my table: onum amt odate cnum snum 3001 18,69 1990-03-10 00:00:00.000 2008 1007 3002 1900,10 1990-03-10 00:00:00.000 ...

热门标签