Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


TSQL


TSQL

Author
Message
vk-kirov
vk-kirov
Hall of Fame
Hall of Fame (3.5K reputation)Hall of Fame (3.5K reputation)Hall of Fame (3.5K reputation)Hall of Fame (3.5K reputation)Hall of Fame (3.5K reputation)Hall of Fame (3.5K reputation)Hall of Fame (3.5K reputation)Hall of Fame (3.5K reputation)

Group: General Forum Members
Points: 3492 Visits: 4408
Paul White NZ
Posted Today @ 4:41:28 PM

... 1 second to read the post and make editing ...

Edited: Today @ 4:41:29 PM by vivek.yadav

Amazing reaction time w00t
Paul White
Paul White
SSChampion
SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)

Group: General Forum Members
Points: 10332 Visits: 11350
vk-kirov (4/7/2010)
Paul White NZ
Posted Today @ 4:41:28 PM

... 1 second to read the post and make editing ...

Edited: Today @ 4:41:29 PM by vivek.yadav

Amazing reaction time w00t

Wow he is fast Laugh
Good of him to front up, admit a mistake and apologise, rather than just replacing his post with NA.
Oh...Unsure

NA



Paul White
SQLPerformance.com
SQLblog.com
@SQL_Kiwi
muhandis
muhandis
SSC-Enthusiastic
SSC-Enthusiastic (173 reputation)SSC-Enthusiastic (173 reputation)SSC-Enthusiastic (173 reputation)SSC-Enthusiastic (173 reputation)SSC-Enthusiastic (173 reputation)SSC-Enthusiastic (173 reputation)SSC-Enthusiastic (173 reputation)SSC-Enthusiastic (173 reputation)

Group: General Forum Members
Points: 173 Visits: 101
Hi aplogize Paul...
Actually i didn't find the nxt page.
that's why i posted that...
But you are much faster then me.. i edited in 1 sec. and you read that post in 1 sec.. :-)

Sorry for that
Paul White
Paul White
SSChampion
SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)

Group: General Forum Members
Points: 10332 Visits: 11350
vivek.yadav (4/7/2010)
Hi aplogize Paul...
Actually i didn't find the nxt page.
that's why i posted that...
But you are much faster then me.. i edited in 1 sec. and you read that post in 1 sec.. :-)
Sorry for that

Laugh all cool Laugh



Paul White
SQLPerformance.com
SQLblog.com
@SQL_Kiwi
john.arnott
john.arnott
UDP Broadcaster
UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)

Group: General Forum Members
Points: 1464 Visits: 3059
malleswarareddy_m (4/6/2010)
john.arnott (4/6/2010)
malleswarareddy_m (4/5/2010)
john.arnott (4/5/2010)
malleswarareddy_m (4/4/2010)
Good QOD.This Question gives good information about bit datatypes.
when we use space or all zero it bit will convert it into zero.If we give numeric(numbers) it will convert it into one.
. . . .

This is true for other numeric datatypes as well. Spaces or empty strings are implicitly converted to zero
DECLARE @MyNum int
SET @MyNum = ' '
-- attempt arithmetic operation
Select @myNum * 4
-- result is 0, not an error.



I think it will throw error when converting it to string datatype except(TRUE/False)

Sorry?? What will cause an error?

Your statement looks to be reversed of what you may have meant -- aren't we talking about converting from strings to numerics? My example of implicit conversion from a string to an int does not cause an error, nor would an empty string, the point being that it's not just conversions to the bit type where empty or blank strings result in zero.

I didn't find a BOL or MSDN article on this specific behavior, but from what I did find, it seems clear that the SQL engine sets the target to zero, then adds the numeric evaluation of the string, ignoring spaces. With nothing else to evaluate, the result remains zero.

You say you "think it will throw error". Did you try it?


your Example is correct.when convert the bit into string it will thrown an error.


What do you mean? your statement that an error will be thrown doesn't make sense to me. Please post an example of an error being created. A short script like this should make it clear.
Declare @MyChar char(10)
Declare @MyBit Bit
set @MyBit = 1234 -- BIT datatype sees as 1
set @MyChar = @myBit -- Implicitly convert 1 to '1'
select @MyBit MyBit, @MyChar MyChar -- Returns: 1 1
set @MyBit = 0 -- Reset so you can see the next step do something
select @MyBit MyBit, @MyChar MyChar -- Returns: 0 1
set @MyBit = @MyChar -- Implicitly convert '1' to 1
select @MyBit MyBit, @MyChar MyChar -- Returns: 1 1


zymos
zymos
Mr or Mrs. 500
Mr or Mrs. 500 (540 reputation)Mr or Mrs. 500 (540 reputation)Mr or Mrs. 500 (540 reputation)Mr or Mrs. 500 (540 reputation)Mr or Mrs. 500 (540 reputation)Mr or Mrs. 500 (540 reputation)Mr or Mrs. 500 (540 reputation)Mr or Mrs. 500 (540 reputation)

Group: General Forum Members
Points: 540 Visits: 259
Good and straight forward question.

Thanks
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search