views:

31

answers:

1

Is it possible to insert data into multiple tables in one statement?

For example, I have two tables (live_products and products) they are the same, except live_products is highly transactional and I keep the record count low (delete once done), where as products holds all historical data, used for reports, etc.

Currently, I'm doing two queries, but it would be nice to do something like

INSERT INTO live_products,products (id, name) values ('','')

This doesn't work... but is there something else?

Thanks!

A: 

It's not possible with a single SQL statement. But why not just write a stored procedure to do it? Then you have the ability to just call the stored procedure with a single statement, which is just as good (actually it's even better, since you can re-use the stored procedure for other things).

dcp