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

Question of the Day for 01 Dec 2005 Expand / Collapse
Author
Message
Posted Wednesday, November 30, 2005 4:05 PM
SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Friday, May 18, 2007 3:36 PM
Points: 10,039, Visits: 1
Comments posted to this topic are about the Question of the Day for 01 Dec 2005 posted at http://www.sqlservercentral.com/testcenter/qod.asp?QuestionID=654.
Post #240964
Posted Thursday, December 1, 2005 3:15 AM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Thursday, April 8, 2010 4:54 PM
Points: 23, Visits: 3

The funny thing is that in

select cast('This is a test' as varchar)

the varchar size defaults to 30, so in this case the full string is returned.

Post #241043
Posted Thursday, December 1, 2005 6:48 AM
SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Wednesday, November 12, 2014 1:50 PM
Points: 2,651, Visits: 792

That's probably tomorrow's question. 

I looked at the MSDN reference, and it had the following line:

The SQL-2003 synonym for char is character.

What is SQL-2003?

Mattie




Post #241096
Posted Thursday, December 1, 2005 7:04 AM
SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Wednesday, May 21, 2014 8:17 AM
Points: 297, Visits: 335

Yeah, I noticed that too.  Probably what SQL - 2005 was supposed to be!

I also saw a new feature that I think I'll really like

Declare @i varchar(max)

Gives you a rather large text store without the text datatype's limitations?  Cool.




Student of SQL and Golf, Master of Neither
Post #241107
Posted Thursday, December 1, 2005 7:56 AM
Hall of Fame

Hall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of Fame

Group: General Forum Members
Last Login: Wednesday, November 12, 2014 10:19 AM
Points: 3,248, Visits: 562
While it was correct, the answer wasn't complete. Per BOL, VARCHAR defaults to 1 when it's used in a data definition or variable declaration statement. BUT it defaults to 30 when used with CAST.

-SQLBill



Post #241144
Posted Thursday, December 1, 2005 8:12 AM
SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Wednesday, May 21, 2014 8:17 AM
Points: 297, Visits: 335

Well, as long as we're being picky, it defaults to 50 when you're using EM to define a field too.

But, if you take the question literally as presented, the answer was correct.  And that's all that really counts for a test.




Student of SQL and Golf, Master of Neither
Post #241157
Posted Thursday, December 1, 2005 9:00 AM
Hall of Fame

Hall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of Fame

Group: General Forum Members
Last Login: Monday, September 29, 2014 2:44 PM
Points: 3,475, Visits: 583

Hi,

The BOL topic "Char and Varchar" says:

".....Remarks

When n is not specified in a data definition or variable declaration statement, the default length is 1. When n is not specified with the CAST function, the default length is 30...."

In the Enterprise Manager you do specify n. 50 is a suggested length. It does not let you to select nothing for n, posts a message that n must be from 1 to 8000. Enterprise Manager is a client application which may have any restrictions specified by its programmers (Microsoft in this case)  where TSQL statements and its rules are applicable to server software SQL Server.




Regards,
Yelena Varshal

Post #241179
Posted Wednesday, December 21, 2005 8:05 AM
SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Saturday, March 7, 2009 11:43 AM
Points: 286, Visits: 9
In response to what is SQL 2003.  That likely does not refer to SQL Server 2003, but, the ANSI SQL 2003 standard.
Post #245853
Posted Tuesday, November 20, 2012 2:57 AM


SSCommitted

SSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommitted

Group: General Forum Members
Last Login: Today @ 6:37 AM
Points: 1,938, Visits: 2,374
nice and easy question....


_______________________________________________________________
To get quick answer follow this link:
http://www.sqlservercentral.com/articles/Best+Practices/61537/
Post #1386764
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse