November 19, 2008 at 2:34 pm
I want to insert into a table from another table, and from a variable
So Table_A has 3 columns (Fld_1, Fld_2, Fld_3), Table_B has 4 columns (Fld_1, Fld_2, Fld_3, FLD_4), . I want to insert the 3 columns from Table_A into table_B, as well as the variable @FLD4 into FLD_4. Can I do that in one statement ?
November 19, 2008 at 3:09 pm
sure;
declare @FLD4 int
SET @FLD4=42
INSERT INTO Table_B(Fld_1, Fld_2, Fld_3, FLD_4)
SELECT Fld_1, Fld_2, Fld_3,@FLD4
FROM Table_A
homebrew01 (11/19/2008)
I want to insert into a table from another table, and from a variableSo Table_A has 3 columns (Fld_1, Fld_2, Fld_3), Table_B has 4 columns (Fld_1, Fld_2, Fld_3, FLD_4), . I want to insert the 3 columns from Table_A into table_B, as well as the variable @FLD4 into FLD_4. Can I do that in one statement ?
Lowell
November 19, 2008 at 3:17 pm
That was easy ! Thanks. I must have had a mental block thinking it wouldn't work that way because it looks like it's trying to select @FLD4 from Table_A
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply