SQL Statement

HI,

I am writing to an sql server/database, what i would like to do is, once records are written to a table in the sql database, i would like to select certain fields from one table and write them to another table in the sql database, how would i do something like this?
Thanks!

mscala
mscalaAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
alokanantConnect With a Mentor Commented:
if col1 and col2, in the two tables tab1 and tab2 are compatible the following query shall work -
 
INSERT INTO Tab1(col1, col2) values(SELECT col1, col2 FROM tab2)

The same can be used for more columns.
this assumes that the tables are in the same database, otherwise qualifiers for the tables will have to be used.

hth
alok.
0
All Courses

From novice to tech pro — start learning today.