Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase «««1516171819»»

one character of data Expand / Collapse
Author
Message
Posted Wednesday, November 18, 2009 8:07 AM
Valued Member

Valued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued Member

Group: General Forum Members
Last Login: Thursday, May 20, 2010 10:04 AM
Points: 54, Visits: 38
Erratum: I wrote too fast:

nvarchar(1) has 2 bytes overhead, which are clearly not needed as spaces were explicitly excluded in the question.


it's of course the fact that we never store 0 chars.
Post #820863
Posted Friday, December 4, 2009 7:53 PM


SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Wednesday, September 24, 2014 6:44 AM
Points: 280, Visits: 89
Well, i'm surprising by the answer (thought about char(1) or nchar(1), and the answer is nvarchar(1) ?
MMmmmm... and what about the 2 bytes added in header ?
I can't agree ! :)
And it's an old question (yes, i go back in past to learn more and more... :D ), i'm surprised the answer is not corrected.
I dismissed the question about july 4th (and its 7 points... yes, i know, indenpendance day but thought it was also link to 'indian costume'/fight the english and reject them to the sea ), so i want this point !



My MCP Transcript (ID : 692471 Access : 109741229)
Post #829330
Posted Friday, December 11, 2009 4:33 AM


SSChasing Mays

SSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing Mays

Group: General Forum Members
Last Login: Friday, January 11, 2013 12:41 PM
Points: 621, Visits: 297
The answer is just authors imagination. - I think you need to clear your basic concepts.

There is only one correct answer to the question - nchar(1)








Bhavesh Patel

http://bhaveshgpatel.wordpress.com/
Post #832826
Posted Thursday, May 20, 2010 9:34 AM
SSC Journeyman

SSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC Journeyman

Group: General Forum Members
Last Login: Wednesday, January 5, 2011 11:12 AM
Points: 80, Visits: 18
I agree it should be nchar(1). The question only states one character data and didn't mention any standards.
Post #925253
Posted Wednesday, July 28, 2010 7:51 AM
Say Hey Kid

Say Hey KidSay Hey KidSay Hey KidSay Hey KidSay Hey KidSay Hey KidSay Hey KidSay Hey Kid

Group: General Forum Members
Last Login: Tuesday, September 23, 2014 6:09 AM
Points: 697, Visits: 356
Answer should be nchar(1),if your have wide thinking about your data.
Post #960046
Posted Monday, August 23, 2010 4:41 AM
Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Tuesday, March 27, 2012 12:08 PM
Points: 1,073, Visits: 51
i think it should be Char(1). would varchar(1) not occupy 2bytes to store length????
Post #973328
Posted Monday, August 23, 2010 4:53 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Today @ 4:48 PM
Points: 6,021, Visits: 8,290
(removed - I thought this was in a different discussion)


Hugo Kornelis, SQL Server MVP
Visit my SQL Server blog: http://sqlblog.com/blogs/hugo_kornelis
Post #973335
Posted Monday, August 23, 2010 5:35 AM
Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Tuesday, March 27, 2012 12:08 PM
Points: 1,073, Visits: 51
not this is about that question "I have a variable that will hold one character of data and will never be a null or an empty space. Which of the following is the best data type to declare that variable?"
i am asking regarding that.

i think i am right. if not please tell me.
Post #973359
Posted Monday, August 23, 2010 5:42 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Today @ 4:48 PM
Points: 6,021, Visits: 8,290
pankaj upadhyay (8/23/2010)
not this is about that question "I have a variable that will hold one character of data and will never be a null or an empty space. Which of the following is the best data type to declare that variable?"
i am asking regarding that.

i think i am right. if not please tell me.

For a variable or column that will always be exactly one character long, the best choice is either char(1) or nchar(1), depending on what range of characters have to be supported.



Hugo Kornelis, SQL Server MVP
Visit my SQL Server blog: http://sqlblog.com/blogs/hugo_kornelis
Post #973361
Posted Monday, August 23, 2010 6:32 AM
Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Tuesday, March 27, 2012 12:08 PM
Points: 1,073, Visits: 51
thanks actually i get confused after reading the ans Either char(1) or varchar(1) may be used. for this question that when we take varchar(1) than will it save length or not.

anyway thanks again.
Post #973392
« Prev Topic | Next Topic »

Add to briefcase «««1516171819»»

Permissions Expand / Collapse