Answered by:
insert hard coding some columns and from a select

Question
-
User496086301 posted
how do we do this
insert into TABLE1 values(id,startdate(9/8/16),enddate(12/31/9999),value,desc)
select id,value,desc from table2.
TIA
Thursday, September 8, 2016 9:14 PM
Answers
-
User-967720686 posted
Hi,
I Think you want this.
insert into Table1 (id, startdate, enddate, value,[desc])
select id,'9/8/2016', '12/31/2199', value,[desc] From Table2- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Thursday, September 8, 2016 11:46 PM -
User-1716253493 posted
INSERT INTO TABLE1 ([tb2_id],[startdate],[enddate],[value],[desc]) SELECT [id],@startdate,@enddate,[value],[desc] FROM TABLE2
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Friday, September 9, 2016 12:07 AM -
User-2057865890 posted
Hi sushsudh,
SQL INSERT INTO SELECT Syntax
INSERT tbl_A (col, col2) SELECT col, col2 FROM tbl_B
all columns from one table to another existing table
INSERT INTO table2 SELECT * FROM table1;
copy only the columns we want to into another existing table
INSERT INTO table2 (column_name(s)) SELECT column_name(s) FROM table1;
reference:
http://www.w3schools.com/sql/sql_insert_into_select.asp
Best Regards,
Chris
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Friday, September 9, 2016 2:18 PM
All replies
-
User-967720686 posted
Hi,
I Think you want this.
insert into Table1 (id, startdate, enddate, value,[desc])
select id,'9/8/2016', '12/31/2199', value,[desc] From Table2- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Thursday, September 8, 2016 11:46 PM -
User-1716253493 posted
INSERT INTO TABLE1 ([tb2_id],[startdate],[enddate],[value],[desc]) SELECT [id],@startdate,@enddate,[value],[desc] FROM TABLE2
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Friday, September 9, 2016 12:07 AM -
User-2057865890 posted
Hi sushsudh,
SQL INSERT INTO SELECT Syntax
INSERT tbl_A (col, col2) SELECT col, col2 FROM tbl_B
all columns from one table to another existing table
INSERT INTO table2 SELECT * FROM table1;
copy only the columns we want to into another existing table
INSERT INTO table2 (column_name(s)) SELECT column_name(s) FROM table1;
reference:
http://www.w3schools.com/sql/sql_insert_into_select.asp
Best Regards,
Chris
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Friday, September 9, 2016 2:18 PM -
User-1404113929 posted
hi,
insert into Table1 (id, startdate, enddate, value,desc)
select id,'9/8/2016', '12/31/2199', value,desc From Table2Thanks,
Murali
Monday, September 12, 2016 11:28 AM