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.
| Author |
Topic |
|
mk_garg20
Constraint Violating Yak Guru
343 Posts |
Posted - 2004-08-08 : 21:34:21
|
| Hello All,Here in posts, i have seen statements like this to insert data into table.INSERT INTO myTable99([ID], [date], value)SELECT 1, '1/4/2004', 100 UNION ALLSELECT 2, '2/4/2004', 10 UNION ALLSELECT 3, '2/4/2004', 90Mostly i use statements likeINSERT INTO myTable99 values(1, '1/4/2004', 100)INSERT INTO myTable99 values(2, '2/4/2004', 10)INSERT INTO myTable99 values(3, '2/4/2004', 90)What is benefit of using select statements to insert data:-Easy syntax or any other reason as well.ThanksManoj |
|
|
timmy
Master Smack Fu Yak Hacker
1242 Posts |
Posted - 2004-08-08 : 21:52:46
|
| The first option only needs one trip to the database. The second one needs 3. I think that the second option is more readable, but I suppose it's personal preference....I use it most of the time to insert testing data and for debugging stuff, so performance isn't really an issue. |
 |
|
|
|
|
|
|
|