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 2000 Forums
 SQL Server Development (2000)
 multiple insertion in a table using a single INSER

Author  Topic 

BuddyRam
Starting Member

17 Posts

Posted - 2007-08-01 : 08:41:16
I have a table test with two columns testid (decimal(9)) and testname(varchar(100)). There is no identoty column or any index in the table.I want to include around 30 items in this table. How can i insert those multiple data into the table using single insert query. i used the following query
INSERT INTO test (testid,testname) values ('1','Others'), ('2','Daily Express'), ('3','Daily Mail'), ('4','The Sun'), ('5','The Times'), ('6','The Star'), ('7','The Mirror'), ('8','The Independent'), ('9','The Guardian'), ('10','The Daily Telegraph');
but it is giving error. Can you give me a better solution.

Cheers
Ram

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2007-08-01 : 08:45:28

INSERT INTO test (testid,testname)
Select '1','Others'
union all
select '2','Daily Express'
union all
select '3','Daily Mail'
union all
.
.
.


Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -