By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,659 Members | 1,714 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,659 IT Pros & Developers. It's quick & easy.

Why does MSSQL server allow the attached code to work

P: 1
Why can we define a integer datatype and pass an empty string in that gets evaluated to zero rather than NULL?

declare @testinteger integer
select @testinteger = ''
select @testinteger

How can we get this to eval to NULL?
Oct 1 '09 #1
Share this Question
Share on Google+
1 Reply

Expert 2.5K+
P: 2,878
Because there's an explicit conversion of data. Read this, on the lower part there's a table that describe the im/explicit conversions.

Try this instead:

Expand|Select|Wrap|Line Numbers
  2. declare @testinteger integer
  3. select @testinteger = NULL
  4. select @testinteger 
Oct 1 '09 #2

Post your reply

Sign in to post your reply or Sign up for a free account.