Saturday, February 25, 2012

Copy a record from one table to another?

Hello,

Is there a way of copying/moving a record from one table to another identical table on the same database using ADO.NET
I can obviously do it the long way (retrieving a record, then pushing it up using a second SQL command)
I was just wondering if there is a way to do it in one database hit using some kind of cool SQL function.Look at the insert ... select statement in Books on Line

insert into table1
(field1, field2)
select
field1, field2
from table2
where recordid = 1|||If there are no identity fields involved, you can exclude the field names:

INSERT INTO table1
SELECT * FROM table2
WHERE id = 3

No comments:

Post a Comment