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 |
|
Giacomo1983
Starting Member
5 Posts |
Posted - 2011-12-14 : 10:52:25
|
| Hi All I'm new here.I wanna fill a db.table with some static data and other data who are result from a select query.. for example:I have my table TOTAL.RESULT with 3 coloumn: ID,NAME,DATAthan I have another table PERSON with 2 coloumn: ID,NAMEThan I wanna fill TOTAL.RESULT Table with a result of select * from PERSONUNIONa value from TOTAL.RESULT(DATA) which is given from the user or is taken from the current data (should be a static data!)Are there some way to do this??Thank you in advance and sorry for my english. |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2011-12-14 : 11:13:34
|
some thing likeINSERT INTO RESULTSELECT ID,NAME, <the static data> FROM PERSON ------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
Giacomo1983
Starting Member
5 Posts |
Posted - 2011-12-14 : 16:23:10
|
| Thanks a lot for your reply! As soon as possible I'll try your code and I'll post a reply. |
 |
|
|
Giacomo1983
Starting Member
5 Posts |
Posted - 2011-12-15 : 06:10:46
|
| YES!! It is working! thanks a lot man.I'll came back if something else goes wrong!! (Hoping not :))Bye |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2011-12-15 : 06:27:49
|
| wc------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
Transact Charlie
Master Smack Fu Yak Hacker
3451 Posts |
Posted - 2011-12-15 : 06:29:12
|
just a tiny thing:It's not good form to do blind inserts like thatINSERT INTO <table>SELECT <foo> Because if the table definition changes (say you move some columns around or add more (nullable) collumns then your INSERT statement will breakIt's better to do:INSERT INTO <table> ( <COLUMN LIST> )SELECT <COLUMN LIST> FROM ..... Charlie===============================================================Msg 3903, Level 16, State 1, Line 1736The ROLLBACK TRANSACTION request has no corresponding BEGIN TRANSACTION |
 |
|
|
|
|
|