Home > Archive > MS SQL Server > March 2006 > SELECT INTO question









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author SELECT INTO question
Jason Huang

2006-03-25, 3:23 am

Hi,

In my SQL Server 2000, I have 2 tables, TableA and TableB.
Actually the TableB is generated from the "SELECT * INTO TableB FROM TableA"
2 weeks ago.
And 2 weeks ago TableA and TableB have same data, saying 500 rows (ID
001~500).
Now TableA has 800 rows, and TableB still has that 500 rows only.
How do I add the 300 rows (ID 501~800) from TableA into TableB?
Thanks for help.


Jason



Daniel Bates

2006-03-25, 3:23 am

INSERT INTO TableB
SELECT * FROM
TableA
WHERE TableA.ID NOT IN (SELECT ID FROM TABLEB)

Ben Nevarez

2006-03-26, 8:23 pm


Unless there is a specific need, with only a few records (800) perhaps it is
better to run the SELECT command again. After all, some of the 500 existing
records could be updated on table A and be different from table B.

Ben Nevarez, MCDBA, OCP
Database Administrator


"Daniel Bates" wrote:

> INSERT INTO TableB
> SELECT * FROM
> TableA
> WHERE TableA.ID NOT IN (SELECT ID FROM TABLEB)
>
>

Sponsored Links





Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive | Programming forum archive

Copyright 2009 droptable.com