Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Delete vs. Select with Table Variable

Status
Not open for further replies.

dukeslater

Technical User
Jan 16, 2001
87
US
Can someone please tell me why this works:

select * from @missingvalues a where exists
(select 1 from @v_responses b
where a.questionID = b.questionID
and a.response = b.response)

but this does not:

delete from @missingvalues a where exists
(select 1 from @v_responses b
where a.questionID = b.questionID
and a.response = b.response)

Error message refers to invalid alias a but when I remove the references to it as follows the result set is empty:

delete from @missingvalues where exists
(select 1 from @v_responses b
where questionID = b.questionID
and response = b.response)

Thanks as always for your help...

 
Try delete a from @missingvalues a

------
"There's a man... He's bald and wears a short-sleeved shirt, and somehow he's very important to me. I think his name is Homer."
(Jack O'Neill, Stargate)
[banghead]
 
Bada bing! Always count on you, and always learn something. Thanks!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top