Created
January 16, 2015 19:20
-
-
Save binki/bf4c4b2b2d976c000a72 to your computer and use it in GitHub Desktop.
Returning 0 rows does not always mean NULL…
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(1 row(s) affected) | |
Id Name | |
----------- ---- | |
1 asdf | |
(1 row(s) affected) | |
x | |
------------ | |
untouched | |
(1 row(s) affected) | |
x | |
------------ | |
NULL | |
(1 row(s) affected) | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DECLARE @x VARCHAR(12); | |
SELECT 1 Id, 'asdf' Name INTO #t; | |
SELECT * FROM #t; | |
SET @x = 'untouched'; | |
SELECT TOP(1) @x = Name FROM #t WHERE Id = 0; | |
SELECT @x x; | |
SET @x = 'untouched'; | |
SET @x = (SELECT TOP(1) Name FROM #t WHERE Id = 0); | |
SELECT @x x; | |
DROP TABLE #t; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment