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


Datatypes In Your Mind


Datatypes In Your Mind

Author
Message
Andy Warren
Andy Warren
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: Moderators
Points: 7940 Visits: 2707
Comments posted to this topic are about the item Datatypes In Your Mind

Andy
SQLAndy - My Blog!
Connect with me on LinkedIn
Follow me on Twitter
stephen.long.1
stephen.long.1
Right there with Babe
Right there with Babe (765 reputation)Right there with Babe (765 reputation)Right there with Babe (765 reputation)Right there with Babe (765 reputation)Right there with Babe (765 reputation)Right there with Babe (765 reputation)Right there with Babe (765 reputation)Right there with Babe (765 reputation)

Group: General Forum Members
Points: 765 Visits: 574
The list shown here includes bit in the list of "exact numeric types".
http://msdn.microsoft.com/en-us/library/ms187752.aspx (Data Types (Transact-SQL))

The definition of bit, shown here, calls it "An integer data type that can take a value of 1, 0, or NULL."
http://msdn.microsoft.com/en-us/library/ms177603.aspx (bit (Transact-SQL))

Since:
- a bit can only store 0 and 1, so it is an "exact number integer data type", as specified in the question
- bit doesn't support negative numbers
- 0-1 is a smaller range than 0-255

The correct answer should be bit.
Eirikur Eiriksson
Eirikur Eiriksson
SSCrazy Eights
SSCrazy Eights (8.2K reputation)SSCrazy Eights (8.2K reputation)SSCrazy Eights (8.2K reputation)SSCrazy Eights (8.2K reputation)SSCrazy Eights (8.2K reputation)SSCrazy Eights (8.2K reputation)SSCrazy Eights (8.2K reputation)SSCrazy Eights (8.2K reputation)

Group: General Forum Members
Points: 8174 Visits: 18182
Good question, thanks!
Did think a bit for a second:-D
Jeff Moden
Jeff Moden
SSC Guru
SSC Guru (52K reputation)SSC Guru (52K reputation)SSC Guru (52K reputation)SSC Guru (52K reputation)SSC Guru (52K reputation)SSC Guru (52K reputation)SSC Guru (52K reputation)SSC Guru (52K reputation)

Group: General Forum Members
Points: 52045 Visits: 40318
Even though I strongly disagree that BIT is an integer datatype simply because it can't be used in certain bits of math, such as a SUM(), I have to agree with Stephen based soley on what the Microsoft documentation says... and it does say...

"An integer data type that can take a value of 1, 0, or NULL."



Anyone that answered "BIT" should get the point... if points matter to anyone.;-)

--Jeff Moden

RBAR is pronounced ree-bar and is a Modenism for Row-By-Agonizing-Row.
First step towards the paradigm shift of writing Set Based code:
Stop thinking about what you want to do to a row... think, instead, of what you want to do to a column.
Although they tell us that they want it real bad, our primary goal is to ensure that we dont actually give it to them that way.
Although change is inevitable, change for the better is not.
Just because you can do something in PowerShell, doesnt mean you should. Wink

Helpful Links:
How to post code problems
How to post performance problems
Forum FAQs
Koen Verbeeck
Koen Verbeeck
SSCoach
SSCoach (18K reputation)SSCoach (18K reputation)SSCoach (18K reputation)SSCoach (18K reputation)SSCoach (18K reputation)SSCoach (18K reputation)SSCoach (18K reputation)SSCoach (18K reputation)

Group: General Forum Members
Points: 18679 Visits: 13249
Misread the question and thought the data type was supposed to store negatives as well...
Need more caffeine.


How to post forum questions.
Need an answer? No, you need a question.
What’s the deal with Excel & SSIS?
My blog at SQLKover.

MCSE Business Intelligence - Microsoft Data Platform MVP
Carlo Romagnano
Carlo Romagnano
Hall of Fame
Hall of Fame (3.8K reputation)Hall of Fame (3.8K reputation)Hall of Fame (3.8K reputation)Hall of Fame (3.8K reputation)Hall of Fame (3.8K reputation)Hall of Fame (3.8K reputation)Hall of Fame (3.8K reputation)Hall of Fame (3.8K reputation)

Group: General Forum Members
Points: 3812 Visits: 3276
stephen.long 56048 (5/5/2014)
The list shown here includes bit in the list of "exact numeric types".
http://msdn.microsoft.com/en-us/library/ms187752.aspx (Data Types (Transact-SQL))

The definition of bit, shown here, calls it "An integer data type that can take a value of 1, 0, or NULL."
http://msdn.microsoft.com/en-us/library/ms177603.aspx (bit (Transact-SQL))

Since:
- a bit can only store 0 and 1, so it is an "exact number integer data type", as specified in the question
- bit doesn't support negative numbers
- 0-1 is a smaller range than 0-255

The correct answer should be bit.


The correct answer IS bit!

+1
Andy, are you hungry?

I run on tuttopodismo
free_mascot
free_mascot
Hall of Fame
Hall of Fame (3.1K reputation)Hall of Fame (3.1K reputation)Hall of Fame (3.1K reputation)Hall of Fame (3.1K reputation)Hall of Fame (3.1K reputation)Hall of Fame (3.1K reputation)Hall of Fame (3.1K reputation)Hall of Fame (3.1K reputation)

Group: General Forum Members
Points: 3073 Visits: 2235
Good One, Thanks!

---------------------------------------------------
"Thare are only 10 types of people in the world:
Those who understand binary, and those who don't."
rhythmk
rhythmk
Right there with Babe
Right there with Babe (720 reputation)Right there with Babe (720 reputation)Right there with Babe (720 reputation)Right there with Babe (720 reputation)Right there with Babe (720 reputation)Right there with Babe (720 reputation)Right there with Babe (720 reputation)Right there with Babe (720 reputation)

Group: General Forum Members
Points: 720 Visits: 1063
Jeff Moden (5/5/2014)
Even though I strongly disagree that BIT is an integer datatype simply because it can't be used in certain bits of math, such as a SUM(), I have to agree with Stephen based soley on what the Microsoft documentation says... and it does say...

"An integer data type that can take a value of 1, 0, or NULL."



Anyone that answered "BIT" should get the point... if points matter to anyone.;-)


Jeff, I think point matters and that is why we have point system for QoTD :-)
Anyway Andy has not mentioned in his explanation that why bit is not correct answer as per the question ;-)

--rhythmk
------------------------------------------------------------------
To post your question use below link

http://www.sqlservercentral.com/articles/Best+Practices/61537/
:-)
Raghavendra Mudugal
Raghavendra Mudugal
SSCommitted
SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)

Group: General Forum Members
Points: 1764 Visits: 2958
Good one Andy, understanding those variable/s from different angle.

hmm, according to the driver, it is tinyint, but the passenger (me) who answered, bit, does not agrees with the driver... and it leads to heated argument... driver loses is mind and lost control.. and we all know the rest what is going to happen... w00t and... now I am scared of SQL.

-//edit; fixed the typo and added "(me)"

ww; Raghu
--
The first and the hardest SQL statement I have wrote- "select * from customers" - and I was happy and felt smart.
sqldoubleg
sqldoubleg
SSC Eights!
SSC Eights! (930 reputation)SSC Eights! (930 reputation)SSC Eights! (930 reputation)SSC Eights! (930 reputation)SSC Eights! (930 reputation)SSC Eights! (930 reputation)SSC Eights! (930 reputation)SSC Eights! (930 reputation)

Group: General Forum Members
Points: 930 Visits: 1347
Thanks for the question,

I guess the author goes more this way

--the smallest exact number integer data type that can't support a negative number

declare @bit bit
set @bit = -1

Command(s) completed successfully.

declare @tinyint tinyint
set @tinyint = -1

Msg 220, Level 16, State 2, Line 5
Arithmetic overflow error for data type tinyint, value = -1.




so certainly bit datatype can get a negative value which will be transformed to 0 or 1.
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