| Author |
Topic |
|
dba123
Yak Posting Veteran
90 Posts |
Posted - 2005-11-07 : 02:25:34
|
| INSERT INTO tbl_City (CityName)Values('Alameda', 'Albany', 'Antioch', 'Bay Point', 'Berkeley', 'Bethel Island', 'Brentwood', 'Byron', 'Canyon','Castro Valley', 'Clayton', 'Concord', 'Crockett', 'Danville', 'Diablo', 'Discovery Bay', 'Dublin', 'El Cerrito','El Sobrante', 'Emeryville', 'Fremont', 'Hayward', 'Hercules', 'Kensington', 'Knightsen', 'Lafayette', 'Livermore','Martinez', 'Moraga', 'Mount Eden', 'Oakland', 'Oakley', 'Orinda', 'Pacheco', 'Piedmont', 'Pinole', 'Pittsburg', 'Pleasanton','Pleasant Hill', 'Point Richmond', 'Port Costa', 'Richmond', 'Rodeo', 'San Leandro', 'San Lorenzo', 'San Pablo','San Ramon', 'Sunol', 'Union City', 'Walnut Creek') |
|
|
chiragkhabaria
Master Smack Fu Yak Hacker
1907 Posts |
Posted - 2005-11-07 : 02:29:07
|
| I guess this wont work for you.. you have to do somthing like this .. Insert Into Tbl_City(City)Select 'Alameda'Union AllSelect 'Antioch'..........Union AllSelect 'Walnum Creek'Complicated things can be done by simple thinking |
 |
|
|
dba123
Yak Posting Veteran
90 Posts |
Posted - 2005-11-07 : 02:33:46
|
| what is the union doing in this case? |
 |
|
|
chiragkhabaria
Master Smack Fu Yak Hacker
1907 Posts |
Posted - 2005-11-07 : 02:37:58
|
| well according to the query which you have posted .. you want to insert the all the records in the column <city> .... so the records has to be in the rows format not in the column format .. you have specified the records in the column format.. I guess you should look out for the Insert in boook online there you will get the better idea about it ..Complicated things can be done by simple thinking |
 |
|
|
afrika
Master Smack Fu Yak Hacker
2706 Posts |
Posted - 2005-11-07 : 02:54:50
|
| Yes, i use the union all statement a lot esp when you have to run multiple inserts into the same column.But for dynamic values we use a while loop. |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2005-11-07 : 03:41:35
|
| >>what is the union doing in this case?Refer Books On Line, SQL Server help file for more informationMadhivananFailing to plan is Planning to fail |
 |
|
|
jen
Master Smack Fu Yak Hacker
4110 Posts |
Posted - 2005-11-07 : 04:18:35
|
| the union will give you a result that is similar to a table or arrayif your values are delimited and passed into a parameter, you can use a split function, check the weblogs/forums for itHTH--------------------keeping it simple... |
 |
|
|
|
|
|