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 |
|
mdhingra01
Posting Yak Master
179 Posts |
Posted - 2004-02-26 : 16:08:02
|
| Here is my situation:I have two tables (1 and 2). Table 1 has columns: {A}. Table 2 has columns{A,B,C,D}. I am performing a insert into Table 2 and providing values. Is there a way for me to pass the values from Table 1.A into Table 2.C?Thanks |
|
|
ehorn
Master Smack Fu Yak Hacker
1632 Posts |
Posted - 2004-02-26 : 16:11:48
|
| [code]INSERT INTO Table2 (a,b,c,d)SELECT v1,v2, t1.A ,v3FROM Table1 t1WHERE <some condition>[/code]EDIT: added alias |
 |
|
|
mdhingra01
Posting Yak Master
179 Posts |
Posted - 2004-02-26 : 16:21:30
|
| I am not sure how to write this query. I am passing fixed values for {a}v1, {b}v2, and {c}v3. For example v1=Qv2=QQv3=QQQthe below statement would not work? Sorry I forgot to mention also that the Table 1 is in Database X and Table 2 is in Database Y.Thanks |
 |
|
|
sphadke
Yak Posting Veteran
55 Posts |
Posted - 2004-02-26 : 16:36:08
|
quote: Originally posted by mdhingra01 I am not sure how to write this query. I am passing fixed values for {a}v1, {b}v2, and {c}v3. For example v1=Qv2=QQv3=QQQthe below statement would not work? Sorry I forgot to mention also that the Table 1 is in Database X and Table 2 is in Database Y.Thanks
maybe something like this??INSERT INTO DatabaseX..Table2 (a,b,c,d)SELECT v1,v2, t1.A ,v3FROM DatabaseY..Table1 t1WHERE <some condition> If any?Sachin |
 |
|
|
|
|
|
|
|