SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


BIT Conversions


BIT Conversions

Author
Message
WayneS
WayneS
SSCrazy Eights
SSCrazy Eights (9.9K reputation)SSCrazy Eights (9.9K reputation)SSCrazy Eights (9.9K reputation)SSCrazy Eights (9.9K reputation)SSCrazy Eights (9.9K reputation)SSCrazy Eights (9.9K reputation)SSCrazy Eights (9.9K reputation)SSCrazy Eights (9.9K reputation)

Group: General Forum Members
Points: 9938 Visits: 10573
Hugo Kornelis (8/14/2012)
WayneS (8/14/2012)
One of the things that I'm trying to learn is to write better QotD questions. It looks like most that have responded here about missing it have acknowledged not reading the question carefully. So, how could this question have been written better?

(The only thing that I can think of is to have bolded the "as a true / 1 value".)


Hi Wayne,

I see nothing wrong with this question. As long as you take the time to read the entire question, I fail to see how one could misunderstand it.
Maybe people who misread the question were only flying over the text and making assumptions on what the question is?


That is exactly what I was aiming for. Thanks Hugo

Wayne
Microsoft Certified Master: SQL Server 2008
Author - SQL Server T-SQL Recipes
If you can't explain to another person how the code that you're copying from the internet works, then DON'T USE IT on a production system! After all, you will be the one supporting it!
Links: For better assistance in answering your questions, How to ask a question, Performance Problems, Common date/time routines,
CROSS-TABS and PIVOT tables Part 1 & Part 2, Using APPLY Part 1 & Part 2, Splitting Delimited Strings

bitbucket-25253
bitbucket-25253
SSCertifiable
SSCertifiable (7.9K reputation)SSCertifiable (7.9K reputation)SSCertifiable (7.9K reputation)SSCertifiable (7.9K reputation)SSCertifiable (7.9K reputation)SSCertifiable (7.9K reputation)SSCertifiable (7.9K reputation)SSCertifiable (7.9K reputation)

Group: General Forum Members
Points: 7869 Visits: 25280
One of the things that I'm trying to learn is to write better QotD questions. It looks like most that have responded here about missing it have acknowledged not reading the question carefully. So, how could this question have been written better?

(The only thing that I can think of is to have bolded the "as a true / 1 value".)

Wayne


Might I suggest that it would have been clearer for myself, and maybe for others, if the wording was:

"How many of these values will be inserted as a 1 into the BitVal column ?"

If everything seems to be going well, you have obviously overlooked something.

Ron

Please help us, help you -before posting a question please read

Before posting a performance problem please read
Tom Thomson
Tom Thomson
SSChampion
SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)

Group: General Forum Members
Points: 14396 Visits: 12213
Hugo Kornelis (8/14/2012)
WayneS (8/14/2012)
One of the things that I'm trying to learn is to write better QotD questions. It looks like most that have responded here about missing it have acknowledged not reading the question carefully. So, how could this question have been written better?

(The only thing that I can think of is to have bolded the "as a true / 1 value".)


Hi Wayne,

I see nothing wrong with this question. As long as you take the time to read the entire question, I fail to see how one could misunderstand it.
Maybe people who misread the question were only flying over the text and making assumptions on what the question is?


+1

Definitely nothing wrong, no trick, no ambiguity, and absolutely straightforward wording.

Tom

roryp 96873
roryp 96873
Ten Centuries
Ten Centuries (1K reputation)Ten Centuries (1K reputation)Ten Centuries (1K reputation)Ten Centuries (1K reputation)Ten Centuries (1K reputation)Ten Centuries (1K reputation)Ten Centuries (1K reputation)Ten Centuries (1K reputation)

Group: General Forum Members
Points: 1040 Visits: 6604
I have to agree that this was a great question and don't see how it could be interpreted any other way. I think the "trap" may have been people knowing how the bit data type behaves in SQL Server and reading only what they wanted to read in the question. I'll admit, I saw it was a bit data type then read "which of the following values will be inserted" and almost went directly to answering without finishing the question since I was familiar with bit conversions. Fortunately I stopped myself, read the ENTIRE question, then answered.
tilew-948340
tilew-948340
Right there with Babe
Right there with Babe (763 reputation)Right there with Babe (763 reputation)Right there with Babe (763 reputation)Right there with Babe (763 reputation)Right there with Babe (763 reputation)Right there with Babe (763 reputation)Right there with Babe (763 reputation)Right there with Babe (763 reputation)

Group: General Forum Members
Points: 763 Visits: 2437
Easy question as I had to face it in my programming some time ago!
Thanks!
EL Jerry
EL Jerry
Hall of Fame
Hall of Fame (4K reputation)Hall of Fame (4K reputation)Hall of Fame (4K reputation)Hall of Fame (4K reputation)Hall of Fame (4K reputation)Hall of Fame (4K reputation)Hall of Fame (4K reputation)Hall of Fame (4K reputation)

Group: General Forum Members
Points: 3990 Visits: 1345
L' Eomot Inversé (8/14/2012)
Hugo Kornelis (8/14/2012)
WayneS (8/14/2012)
One of the things that I'm trying to learn is to write better QotD questions. It looks like most that have responded here about missing it have acknowledged not reading the question carefully. So, how could this question have been written better?

(The only thing that I can think of is to have bolded the "as a true / 1 value".)


Hi Wayne,

I see nothing wrong with this question. As long as you take the time to read the entire question, I fail to see how one could misunderstand it.
Maybe people who misread the question were only flying over the text and making assumptions on what the question is?


+1

Definitely nothing wrong, no trick, no ambiguity, and absolutely straightforward wording.

I also agree there is nothing wrong with it. We must read and analyze the question.

Great question, Wayne!!

"El" Jerry.

"A watt of Ottawa" - Gerardo Galvan

To better understand your help request, please follow these best practices.
SQLRNNR
SQLRNNR
SSC-Dedicated
SSC-Dedicated (32K reputation)SSC-Dedicated (32K reputation)SSC-Dedicated (32K reputation)SSC-Dedicated (32K reputation)SSC-Dedicated (32K reputation)SSC-Dedicated (32K reputation)SSC-Dedicated (32K reputation)SSC-Dedicated (32K reputation)

Group: General Forum Members
Points: 32653 Visits: 18558
Good job Wayne - good question.



Jason AKA CirqueDeSQLeil
I have given a name to my pain...
MCM SQL Server, MVP


SQL RNNR

Posting Performance Based Questions - Gail Shaw

Nadrek
Nadrek
SSCommitted
SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)

Group: General Forum Members
Points: 1913 Visits: 2729
Thomas Abraham (8/14/2012)
Excellent question. I particularly like questions, like this one, that highlight areas where the behavior is not as one might think, or is different than you might find in other languages. These are the gotchas that you have to know. Thanks!


Agreed. SQL syntax is essentially old C syntax - 0 is false, nonzero is true.
buntyteg
buntyteg
SSC-Addicted
SSC-Addicted (436 reputation)SSC-Addicted (436 reputation)SSC-Addicted (436 reputation)SSC-Addicted (436 reputation)SSC-Addicted (436 reputation)SSC-Addicted (436 reputation)SSC-Addicted (436 reputation)SSC-Addicted (436 reputation)

Group: General Forum Members
Points: 436 Visits: 460
in correct answer -1,1 is correct

but how 25 is correct

means to say... in bit datatype how we can store 25 (2 digit) value

??????
Hugo Kornelis
Hugo Kornelis
SSChampion
SSChampion (11K reputation)SSChampion (11K reputation)SSChampion (11K reputation)SSChampion (11K reputation)SSChampion (11K reputation)SSChampion (11K reputation)SSChampion (11K reputation)SSChampion (11K reputation)

Group: General Forum Members
Points: 11086 Visits: 12001
buntyteg (8/14/2012)
means to say... in bit datatype how we can store 25 (2 digit) value

No. Any value other than 0 is converted to 1. So 1 is stored as given, and both -1 and 25 are converted to 1. (Which, by some tools, is interpreted and shown as true).


Hugo Kornelis, SQL Server MVP
Visit my SQL Server blog: http://sqlblog.com/blogs/hugo_kornelis
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