The MICROSOFT SQL SERVER has the following table:
CREATE TABLE [T1]
(
[ID] int IDENTITY (1, 1) NOT NULL,
[col1] int NOT NULL,
[col2] int NOT NULL,
[col3] int NULL,
[col4] datetime NOT NULL DEFAULT (getdate()),
[col5] datetime NOT NULL DEFAULT (getdate())
)
I want to write an insert statement that selects 2 columns from another table and inserts the entire other column as NULL or default. This is what I have tried so far (but this does not work):
INSERT INTO [T1] ([col1],[col2], [COL3])
SELECT [1column],[2column],NULL
FROM [T2]
When I right-click on table T1 and select an open table, the table has only 2 columns, even if the column “folder” in the object explorer has all the columns
What I want to achieve is to have in T1: in Col1 and COL2 the result is SELECT and COL3 NULL, and in COL4 and COL5 - the default value!
Uince
source
share