Mis-matched table var column matches anything - by AndrewMc

Status : 

  Won't Fix<br /><br />
		Due to several factors the product team decided to focus its efforts on other items.<br /><br />
		A more detailed explanation for the resolution of this particular item may have been provided in the comments section.

Sign in
to vote
ID 786085 Comments
Status Closed Workarounds
Type Bug Repros 0
Opened 5/2/2013 12:44:03 AM
Access Restriction Public


I wrote an sp to delete data using a one field table variable to hold values to be deleted.
Only 3 values were put in to the table var, but when compared to a Product table, all rows were matched and deleted.  I had miss-named the table var field in the sp delete statements.
The design-time compiler let the mistake through, and apparently the run-time engine said "can't find ProductID in table var" I know I'll match Product.ProductId with itself.
So everything was deleted instead of getting an error.
Happens in 2008 and 2012
Sign in to post a comment.
Posted by Manbeen [MSFT] on 7/18/2013 at 2:24 PM

Thank you for submitting this feedback. After carefully evaluating all of the bugs in our pipeline, we are closing bugs that we will not fix in the current or future versions of SQL Server.

Posted by Vladimir Moldovanenko on 5/6/2013 at 7:36 AM
You need to code properly, using table aliases and then it will be no problem.
select * from dbo.ProductsInColours p where p.ProductID in (select t.ProductID from @ProdsToDel t) --10500 rows