Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
consulBanana
Starting Member
2 Posts |
Posted - 2004-03-26 : 16:59:01
|
| Okay, this has me stumped. I thought I had a serious bug in a stored procedure that was deleting every row in a table whenever it ran, but instead the query in question wasn't even running. The weird part is that I made a mistake in the subquery referencing a row in a temporary table that doesn't even exist! Can anyone verify that this script should definitely not work, or hand me the cluex4 so I can mash my own head in?/*@@VERSIONMicrosoft SQL Server 2000 - 8.00.760 (Intel X86) Dec 17 2002 14:22:05 Copyright (c) 1988-2003 Microsoft Corporation Developer Edition on Windows NT 5.0 (Build 2195: Service Pack 4) */USE NorthwindGO--Create a little table with car themed columnsCREATE TABLE MyCar( hornID UNIQUEIDENTIFIER, brakeID UNIQUEIDENTIFIER)GO--Insert a test rowINSERT MyCar(hornID, brakeID)VALUES(NEWID(), NEWID())--Use MyCar to create the temporary table MyShoe,--with shoelaceID as a columnSELECT brakeID shoelaceIDINTO #MyShoeFROM MyCar--Validate that #MyShoe has only one column, shoelaceIDSELECT *FROM #MyShoe--Try to select a column from #MyShoe that doesn't existSELECT *FROM MyCarWHERE hornID IN( SELECT hornID --!!! Why doesn't this give me an error? !!! FROM #MyShoe)GO |
|
|
ehorn
Master Smack Fu Yak Hacker
1632 Posts |
|
|
consulBanana
Starting Member
2 Posts |
Posted - 2004-03-26 : 17:36:06
|
| Truly I do see the light. Thanks! |
 |
|
|
|
|
|