This is something I ran into today and am curious if anyone knows anything about this....
I was working on something earlier and executed T-SQL command. I noticed a typo in my code after the query had executed successfully
. The offending code looked something like this...
Though logic would dictate otherwise, the above query runs successfully on 2008 & 2012. It appears that SQL Server treats double single quotes as a zero (0). I was curious so I ran these:
The first statement returned a 1, the second returned a 0. This is what I expected: 5 is numeric, '' is not.
Then I ran the following and it appears that ''=0
SELECT CAST('' AS int)
SELECT REPLICATE(CAST('' AS int),5)
After a bunch of Google searching I was not able to find anything about this...
Is this a bug, is my server haunted? Anyone know anything about this?
-- Alan Burstein
Best practices for getting help on SQLServerCentral
Need to split a string? Try DelimitedSplit8K
Need a pattern-based splitter? Try PatternSplitCM
Need to remove or replace those unwanted characters? Try PatExclude8K
. "I can't stress enough the importance of switching from a 'sequential files' mindset to 'set-based' thinking. After you make the switch, you can spend your time tuning and optimizing your queries instead of maintaining lengthy, poor-performing code. " -- Itzek Ben-Gan 2001