SQL Clone
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
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: Moderators
Points: 14881 Visits: 2730
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
SSC Eights!
SSC Eights! (923 reputation)SSC Eights! (923 reputation)SSC Eights! (923 reputation)SSC Eights! (923 reputation)SSC Eights! (923 reputation)SSC Eights! (923 reputation)SSC Eights! (923 reputation)SSC Eights! (923 reputation)

Group: General Forum Members
Points: 923 Visits: 599
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
SSC-Insane
SSC-Insane (20K reputation)SSC-Insane (20K reputation)SSC-Insane (20K reputation)SSC-Insane (20K reputation)SSC-Insane (20K reputation)SSC-Insane (20K reputation)SSC-Insane (20K reputation)SSC-Insane (20K reputation)

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

Group: General Forum Members
Points: 114615 Visits: 41388
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.
If you think its expensive to hire a professional to do the job, wait until you hire an amateur. -- Red Adair

Helpful Links:
How to post code problems
How to post performance problems
Forum FAQs
Koen Verbeeck
Koen Verbeeck
SSC-Dedicated
SSC-Dedicated (34K reputation)SSC-Dedicated (34K reputation)SSC-Dedicated (34K reputation)SSC-Dedicated (34K reputation)SSC-Dedicated (34K reputation)SSC-Dedicated (34K reputation)SSC-Dedicated (34K reputation)SSC-Dedicated (34K reputation)

Group: General Forum Members
Points: 34211 Visits: 13270
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
SSCertifiable
SSCertifiable (5.8K reputation)SSCertifiable (5.8K reputation)SSCertifiable (5.8K reputation)SSCertifiable (5.8K reputation)SSCertifiable (5.8K reputation)SSCertifiable (5.8K reputation)SSCertifiable (5.8K reputation)SSCertifiable (5.8K reputation)

Group: General Forum Members
Points: 5826 Visits: 3340
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
SSCarpal Tunnel
SSCarpal Tunnel (4.7K reputation)SSCarpal Tunnel (4.7K reputation)SSCarpal Tunnel (4.7K reputation)SSCarpal Tunnel (4.7K reputation)SSCarpal Tunnel (4.7K reputation)SSCarpal Tunnel (4.7K reputation)SSCarpal Tunnel (4.7K reputation)SSCarpal Tunnel (4.7K reputation)

Group: General Forum Members
Points: 4735 Visits: 2248
Good One, Thanks!

---------------------------------------------------
"Thare are only 10 types of people in the world:
Those who understand binary, and those who don't."
rhythmk
rhythmk
Ten Centuries
Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)

Group: General Forum Members
Points: 1100 Visits: 1084
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
SSCrazy
SSCrazy (2.5K reputation)SSCrazy (2.5K reputation)SSCrazy (2.5K reputation)SSCrazy (2.5K reputation)SSCrazy (2.5K reputation)SSCrazy (2.5K reputation)SSCrazy (2.5K reputation)SSCrazy (2.5K reputation)

Group: General Forum Members
Points: 2504 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
Ten Centuries
Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)

Group: General Forum Members
Points: 1237 Visits: 1362
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