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

CAST Expand / Collapse
Author
Message
Posted Tuesday, May 19, 2009 9:15 PM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Wednesday, July 2, 2014 8:22 AM
Points: 148, Visits: 185
Comments posted to this topic are about the item CAST
Post #720280
Posted Wednesday, May 20, 2009 8:30 AM
SSCommitted

SSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommitted

Group: General Forum Members
Last Login: Yesterday @ 10:56 AM
Points: 1,509, Visits: 2,162
Interesting, I didn't know that.

Just for fun I just created a dummy table with a VARCHAR column that I didn't specify the length for, and it made it of length 1.


Jason Shadonix
MCTS, SQL 2005
Post #720601
Posted Wednesday, May 20, 2009 9:07 AM


SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Tuesday, February 11, 2014 4:12 PM
Points: 2,007, Visits: 768
Jason Shadonix (5/20/2009)
Interesting, I didn't know that.

Just for fun I just created a dummy table with a VARCHAR column that I didn't specify the length for, and it made it of length 1.


That's expected for both CHAR and VARCHAR, according to the Books Online when the length is not given the default is 1 during definition and 30 when casting.

http://msdn.microsoft.com/en-us/library/aa258242(SQL.80).aspx
Post #720651
Posted Thursday, May 21, 2009 8:40 AM
Valued Member

Valued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued Member

Group: General Forum Members
Last Login: Monday, January 4, 2010 12:04 PM
Points: 54, Visits: 67
I didn't know that either. I kept thinking the default length when creating a table using the designer is 50. I knew that answer was too easy... :)

Not very good consistency... 3 (50, 30, or 1) different default lengths depending on how you are creating the field.
Post #721394
Posted Thursday, May 21, 2009 11:14 AM


SSCarpal Tunnel

SSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal Tunnel

Group: General Forum Members
Last Login: Sunday, August 17, 2014 3:10 PM
Points: 4,013, Visits: 6,098
Good question, and good to know. I answered 1 because that's the length you get when you declare a string as varchar without a length. I'm surprised at the inconsistency but glad to be made aware of it.


__________________________________________________

Against stupidity the gods themselves contend in vain. -- Friedrich Schiller
Stop, children, what's that sound? -- Stephen Stills
Post #721521
Posted Thursday, May 21, 2009 12:59 PM
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: Thursday, July 17, 2014 10:56 AM
Points: 3,924, Visits: 1,607
Good question. Never knew that.

SQL DBA.
Post #721614
Posted Thursday, August 8, 2013 6:07 AM


SSCommitted

SSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommitted

Group: General Forum Members
Last Login: Friday, July 25, 2014 12:34 AM
Points: 1,888, Visits: 2,326
good and easy one....
thanks :)



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

Add to briefcase

Permissions Expand / Collapse