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
 Transact-SQL (2000)
 Stupid newbie question - Inserting multiple rows

Author  Topic 

Fromper
Starting Member

33 Posts

Posted - 2006-09-26 : 10:38:29
Sorry if this is a dumb question, but the books I have don't specifically address this.

Is it possible to do an INSERT INTO ... VALUES query to insert multiple rows at once? I know you can do multiple rows with INSERT INTO ... SELECT, but what if you just have 10 - 15 rows you want to insert by typing out the values manually? Do you have to do a separate INSERT query for each row?

--Richard

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2006-09-26 : 10:55:45
You can use hard-coded values in the select like this:

Insert into emp(eno, ename, sal)
select 1, 'abc', 10000 union all
select 2, 'pqr', 20000 union all
select 3, 'xyz', 30000


BTW, there is nothing wrong in asking questions - whether they are elementary or not - nobody knows everything...
But, it's wrong to ask same type of question ten times.

Harsh Athalye
India.
"Nothing is Impossible"
Go to Top of Page

Fromper
Starting Member

33 Posts

Posted - 2006-09-26 : 12:01:26
Thanks. That's good to know. I never knew you could do a SELECT without a FROM, but if you're typing your own values instead of pulling field names, I guess it makes sense.

I'll try not to ask the same stupid questions 10 times. Instead, I'll stick to asking 10 different stupid questions. :P

--Richard
Go to Top of Page

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2006-09-26 : 12:55:29
That's better

Harsh Athalye
India.
"Nothing is Impossible"
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2006-09-26 : 13:15:28
quote:
Originally posted by Fromper

I guess it makes sense.



Only on this platform, don't try this with DB2 or Oracle




Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx

Add yourself!
http://www.frappr.com/sqlteam
Go to Top of Page
   

- Advertisement -