这个问题在这里已经有了答案:
如何插入多行而不重复声明中的“INSERT INTO dbo.Blah”部分? 12个答案这里的这些StackOverflow问题, 在这里和这里都说同样的事情,但我不能让它在SSMS或SQLFiddle中运行
CREATE TABLE #Names ( Name1 VARCHAR(100), Name2 VARCHAR(100) ) INSERT INTO #Names (Name1, Name2) VALUES ('Matt', 'Matthew'), ('Matt', 'Marshal'), ('Matt', 'Mattison')当我执行SSMS时,插入失败,并在VALUES后的第一行显示以下消息
Msg 102,Level 15,State 1,Line 10 ','附近的语法不正确。
此小提琴运行时没有#号,并且在表名为#Names时成功执行模式,但当我尝试从表中选择*时,出现以下消息
无效的对象名称'#NAMES'.: SELECT * FROM #NAMES
SQL Server 2012是否支持多个插入?
更新对不起,你好。 SQL新手没有意识到SSMS 2012将被限制在我所在的任何服务器上
SELECT @@VERSION --Returns: Microsoft SQL Server 2005 - 9.00.5057.00 (X64) --Mar 25 2011 13:33:31 --Copyright (c) 1988-2005 Microsoft Corporation --Standard Edition (64-bit) on Windows NT 5.2 (Build 3790: Service Pack 2)This question already has an answer here:
How do I insert multiple rows WITHOUT repeating the “INSERT INTO dbo.Blah” part of the statement? 13 answersThese StackOverflow questions here, here, and here all say the same thing, but I can't get it to run in SSMS or SQLFiddle
CREATE TABLE #Names ( Name1 VARCHAR(100), Name2 VARCHAR(100) ) INSERT INTO #Names (Name1, Name2) VALUES ('Matt', 'Matthew'), ('Matt', 'Marshal'), ('Matt', 'Mattison')When I execute this is SSMS, the insert fails with the following message on the first line after VALUES
Msg 102, Level 15, State 1, Line 10 Incorrect syntax near ','.
This Fiddle runs without the # sign, and the schema executes successfully when the table name is #Names, but I get the following message when I try to select * from the table
Invalid object name '#NAMES'.: SELECT * FROM #NAMES
Does SQL Server 2012 support multiple inserts?
Update: Apparently accessing a 2005 server on SSMS 2012....
SELECT @@VERSION --Returns: Microsoft SQL Server 2005最满意答案
是的,SQL Server 2012支持多个插入 - 该功能是在SQL Server 2008中引入的。
这让我想知道您是否拥有Management Studio 2012,但您确实连接到了SQL Server 2005实例......
你从SELECT @@VERSION获得什么版本的SQL Server 引擎 ?
Yes, SQL Server 2012 supports multiple inserts - that feature was introduced in SQL Server 2008.
That makes me wonder if you have Management Studio 2012, but you're really connected to a SQL Server 2005 instance ...
What version of the SQL Server engine do you get from SELECT @@VERSION ??
更多推荐
发布评论