Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 How to apply multiple insert statement

Author  Topic 

on9west
Starting Member

2 Posts

Posted - 2008-06-16 : 01:18:56
Hello everyone

I am using MS SQL Server Management Studio Express. When I apply multiple insert statement, it doesn't allow me to do so. I have to do it one by one, which is time consuming.

Sample
INSERT INTO table (col_a,col_b) VALUES (1,1)
INSERT INTO table (col_a,col_b) VALUES (2,2)
INSERT INTO table (col_a,col_b) VALUES (3,3)

Any ideas? I want to do it in one go. Thank you very much.

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-06-16 : 01:48:19
[code]INSERT INTO table (col_a,col_b)
SELECT 1,1
UNION ALL
SELECT 2,2
UNION ALL
SELECT 3,3
....[/code]

However if you've SQL 2008 you can use it like this

[code]INSERT INTO table (col_a,col_b)
VALUES (1,1),
(2,2),
(3,3)[/code]
Go to Top of Page
   

- Advertisement -