chuckd
chuckd

Reputation: 14600

why doesn't my nested insert statement work?

insert into myTable (Id) values (
       select id from someTable where seriesid not in (120, 130, 110, 300)
)

I get this error message in SSMS:

Msg 156, Level 15, State 1, Line 1 Incorrect syntax near the keyword 'select'. Msg 102, Level 15, State 1, Line 1 Incorrect syntax near ')'.

Upvotes: 0

Views: 84

Answers (1)

juergen d
juergen d

Reputation: 204854

If you perform a select in an insert then you may skip the values part

insert into myTable (Id) 
select id 
from someTable 
where seriesid not in (120, 130, 110, 300)

Upvotes: 5

Related Questions