Question about INSERT INTO TABLE SELECT...

Last Post 03 Jun 2009 08:15 AM by kj2w2ndAccount. 0 Replies.
AddThis - Bookmarking and Sharing Button
Author Messages
kj2w2ndAccount
New Member
New Member

--
03 Jun 2009 08:15 AM
Can someone help me with a simple INSERT INTO? I have 4 tables (1-4) and are set up like this:
Table_1 : col1, col2
Table_2 : col1, col2
Table_3 : col1
Table_4 : col1, col2, col3

If I put 5 rows into Table_1 and run the following tsql I get an error on Table_4:

INSERT INTO test.dbo.Table_2
SELECT [col1],
[col2]
FROM test.dbo.Table_1

INSERT INTO test.dbo.Table_3
SELECT
[col1]
FROM test.dbo.Table_1
INSERT INTO test.dbo.Table_4
SELECT [col1],
[col2]
FROM test.dbo.Table_1
The error is this: Insert Error: Column name or number of supplied values does not match table definition.

If im going to do an INSERT INTO Table_4 from Table_1 why does Table_4 care to fill [col3] if Table_4.[col3] allows NULL's?

J


Acceptable Use Policy
---