May 20, 2009 at 8:30 am
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.
The Redneck DBA
May 20, 2009 at 9:07 am
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
May 21, 2009 at 8:40 am
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.
May 21, 2009 at 11:14 am
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? Everybody look what's going down. -- Stephen Stills
May 21, 2009 at 12:59 pm
Good question. Never knew that.
SQL DBA.
August 8, 2013 at 6:07 am
good and easy one....
thanks 🙂
_______________________________________________________________
To get quick answer follow this link:
http://www.sqlservercentral.com/articles/Best+Practices/61537/
Viewing 7 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply