I'm trying to insert data into a table using a few columns that are hard-coded or are static values and then the rest of the datat selected from another table. I've tried the following query:
insert into wtdocversion
values (( select id from wtdocmaster),'col2','col3');
But this generates an error:
Msg 512, Level 16, State 1, Line 1
Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression.
Best Answer
You want to drop the
values
part of the query and do anINSERT\SELECT
.This is really basic SQL and you can read more about it in BOL.