Link to home
Start Free TrialLog in
Avatar of EYoung
EYoungFlag for United States of America

asked on

How append records from table

How can I append records from one MS SQL table (Table A) into another MS SQL table (TableB)?

Both tables are identical in design but contain different records.  There are 10,000 records in each table so when the combining is done, the resultant table should have exactly 20,000 records.

Each table has 50 fields so I would like to use the asterisk (*) instead of specifing each field in each table.

I am using SQL Server 2000.

I have tried to use the OUTER JOIN command but it causes a cartesian result.

I just want to add 10,000 new records to an existing table.

Thank you for the help
ASKER CERTIFIED SOLUTION
Avatar of Jim Horn
Jim Horn
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
The test script for SQL 2008 R2 is below.

CREATE TABLE test1 (id int, full_name varchar(50))

INSERT INTO test1 (id, full_name)
VALUES (1, 'Jack Black'), (2, 'Joe Green'), (3, 'Jake Brown')

CREATE TABLE test2 (id int, full_name varchar(50))

INSERT INTO test2 (id, full_name)
VALUES (1, 'Jack Black'), (2, 'Joe Green'), (3, 'Jake Brown')

INSERT INTO test1
SELECT * FROM test2

SELECT * FROM test1
SELECT * FROM test2

>Each table has 50 fields so I would like to use the asterisk (*) instead
Under normal circumstances this is not a best practice, as any change to the schema of one table that was not made in the other would cause the INSERT ... * statement to throw an error.
Avatar of EYoung

ASKER

Thank you