January 26, 2012 at 5:50 am
Good question, thansk for submitting.
http://brittcluff.blogspot.com/
January 26, 2012 at 6:11 am
Good question, which illustrates the importance of defining the maximum data length.
Thanks,
Matt
January 26, 2012 at 6:17 am
One has to wonder at what point will Microsoft add configuration switches (defaulted to force developers to use correct variable declarations) that would allow you to either work with backwards compatibility for things like this versus causing an error because you have not explicitly set the length of your varchar / nvarchar variables for new development projects. IMHO, continuing to allow syntax such as this just allows old habits to continue to live on without indicating that you have code that really needs to be addressed.
January 26, 2012 at 6:59 am
You would have gotten me if one of the answers was
123456789012345678901234567890 and
123456789012345678901234567890
but without that I had to dig a bit deeper.
Good question, thanks.
January 26, 2012 at 7:15 am
You mean like option 4?
123456789012345678901234567890 and 123456789012345678901234567890
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
January 26, 2012 at 7:56 am
Loved the question and got it right because I had issues with some old code before.
Thank you for this straightforward question!
Best regards,
Andre Guerreiro Neto
Database Analyst
http://www.softplan.com.br
MCITPx1/MCTSx2/MCSE/MCSA
January 26, 2012 at 8:11 am
Nice question. And this is why we always declare lengths for variable data types.
January 26, 2012 at 8:34 am
I knew about VARCHAR defaulting to length of 1, but I learned today about the CASE/CAST 30 byte truncation.
So.
Anyone know why MS created two different default data lengths? It seems like redundant inconsistency....
Rich
January 26, 2012 at 8:41 am
Who knows. The cause of this is likely buried somewhere in the past.
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
January 26, 2012 at 8:45 am
KWymore (1/26/2012)
Nice question. And this is why we always declare lengths for variable data types.
Agreed
Jason...AKA CirqueDeSQLeil
_______________________________________________
I have given a name to my pain...MCM SQL Server, MVP
SQL RNNR
Posting Performance Based Questions - Gail Shaw[/url]
Learn Extended Events
January 26, 2012 at 9:02 am
January 26, 2012 at 9:39 am
I was not aware of this. Definatly will keep this in mind for the future.
January 26, 2012 at 9:42 am
tks for the question.
January 26, 2012 at 1:45 pm
I always declare the length so I wasn't sure what the defaults were but assumed that was what the question was about.
Good question.
Viewing 15 posts - 16 through 30 (of 47 total)
You must be logged in to reply to this topic. Login to reply