2015-04-25 59 views
0

我是使用SQL Server的新手,並且遇到此問題。我不知道如何連接才能將多個值插入到一個列表中。將多個值插入到SQL Server表中

INSERT INTO Table (Column) 
VALUES ('Name'+','+' Last name',);,('Name'+','+'Last name',); 

而且我得到這個錯誤:

Msg 102, Level 15, State 1, Line 3
Incorrect syntax near ','.

+0

可能重複[如何插入多行而不重複聲明的「INSERT INTO dbo.Blah」部分?](http://stackoverflow.com/questions/2624713/how-do- i-insert-multiple-rows-without-repeating-the-insert-into-dbo-blah-part) –

回答

0
INSERT INTO Table (Column) 
VALUES ('Name'+','+ 'Last name') --<-- no comma required inside the paranthesis 
     ,('Name'+','+ 'Last name'); --<-- only need semi-colon here 
0

使用時應使用|| concatenate的符號。 例如:SELECT first_name || ' ' || last_name FROM hr.employees;

+0

這是針對sql server的。你不能使用'||'連接 – ughai