Site Sponsored By: SQLDSC - SQL Server Desired State Configuration
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.
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 allselect 2, 'pqr', 20000 union allselect 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 AthalyeIndia."Nothing is Impossible"
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
harsh_athalye
Master Smack Fu Yak Hacker
5581 Posts
Posted - 2006-09-26 : 12:55:29
That's better Harsh AthalyeIndia."Nothing is Impossible"
X002548
Not Just a Number
15586 Posts
Posted - 2006-09-26 : 13:15:28
quote:Originally posted by Fromper I guess it makes sense.