w0051977
w0051977

Reputation: 15817

SELECT statement to generate INSERT value

Is is possible to do this in SQL i.e. use a SELECT statement to generate an INSERT value:

insert into  [processing].dbinputfields ([description], fieldtypeid, datasetid)
values ('ID', + select id from [processing].dbfieldtype where description='URN' + ,6)

I know I could assign the value of ID to a variable (@ID). However, I was wandering if it could be done like the SQL statement above.

Upvotes: 0

Views: 75

Answers (1)

gzaxx
gzaxx

Reputation: 17600

You can do insert select statement in SQL Server.

Change your query to this:

insert into  [processing].dbinputfields ([description], fieldtypeid, datasetid)
select 'ID', id, 6
from [processing].dbfieldtype
where description = 'URN'

Upvotes: 2

Related Questions