J.J.Baxter - My place on the web - interests, hobbies, thoughts & ruminations
Home / Blog
Books
Links
Images
Aug Sep-2010 Oct
SMTWTFS
2930311234
567891011
12131415161718
19202122232425
262728293012
3 4 5 6 7 8 9
Reset Calendar
Snorg Girls
Programming Tips
Sherlock Holmes
Mythbusters
Gallipoli
Nova Science Now
Ajax Loading Images
The Girls of Dr. Who
Keratosis Pilaris (KP)
Amazing Water
Buy me a drink? I'll have a Cappuccino, thanks.
Random Images
Random Link
Earth Sandwich
Random Book
Digital Fortress
by Dan Brown






All Rights Reserved 2008
JJBaxter.com

J.J.Baxters Development Tips & Snippets
backBack
 Copy records from one table to another (SQL : 13-Jul-2007)
This took a while to get to work, even with googles help

To copy records from one table to another the general syntax is:

INSERT INTO tableA SELECT FROM tableB

Now thats ok provided the field names and types are identical and theres no identity fields involved.

If you have different field names then they need to be specified like this:

INSERT INTO tableA (surname,firstname) SELECT (s_name,f_name) FROM tableB

If there are identity fields involved then you can either SET IDENTITY OFF (scary) or specify all the fields excluding the identity fields:

INSERT INTO tableA (field1,field2,field3...) SELECT (field1,field2,field3...) FROM tableB



Ref Link: http://www.markcarter.me.uk/computing/sql/insert_into.htm