|
|
|
SSC-Enthusiastic
      
Group: General Forum Members
Last Login: Yesterday @ 12:25 PM
Points: 126,
Visits: 118
|
|
| Comments posted to this topic are about the item CAST
|
|
|
|
|
Ten Centuries
      
Group: General Forum Members
Last Login: Monday, May 20, 2013 4:06 PM
Points: 1,409,
Visits: 2,027
|
|
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
|
|
|
|
|
SSCrazy
      
Group: General Forum Members
Last Login: Thursday, April 05, 2012 2:35 PM
Points: 2,007,
Visits: 767
|
|
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
|
|
|
|
|
Valued Member
      
Group: General Forum Members
Last Login: Monday, January 04, 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.
|
|
|
|
|
Hall of Fame
       
Group: General Forum Members
Last Login: Yesterday @ 3:05 PM
Points: 3,789,
Visits: 5,547
|
|
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
|
|
|
|
|
Hall of Fame
       
Group: General Forum Members
Last Login: Friday, March 15, 2013 2:43 PM
Points: 3,924,
Visits: 1,554
|
|
Good question. Never knew that.
SQL DBA.
|
|
|
|