How to insert a combination of explicit values ​​and data from another table

I know two ways to insert data into a table

Method 1: Explicit Values

INSERT INTO table ('field1', 'field2', 'field3') VALUES ('value1', 'value2', 'value3') 

Method 2: copy data from another table

 INSERT INTO table SELECT 'field1', 'field2', 'field3' FROM otherTable 

Both work only if all fields are filled the same way. I need to paste into the same line a mixture of explicit values ​​and copied data. Is it possible?

+6
sql sql-server
source share
1 answer

Yes it is. (Note that in your method 2 example, this would actually enter explicit values, not data from another table).

eg.

 INSERT SomeTable(FieldA, FieldB, FieldC) SELECT FieldA, FieldB, 'Explicit Value' FROM SomeOtherTable 
+9
source share

All Articles