|
|
|
SSCommitted
      
Group: General Forum Members
Last Login: Friday, May 17, 2013 2:53 AM
Points: 1,529,
Visits: 359
|
|
thanks, this explains everything...
DECLARE @Testvar VARCHAR; SET @Testvar = 'Red'; print @Testvar;
|
|
|
|
|
Ten Centuries
      
Group: General Forum Members
Last Login: 2 days ago @ 7:15 AM
Points: 1,352,
Visits: 1,738
|
|
Excellent question! I don't think it's so much about relying on a default (bad practice) so much as forgetting to specify the length, which may not result in a syntax error, and may return results which are incorrect. Thanks for the reality check.
|
|
|
|
|
Right there with Babe
      
Group: General Forum Members
Last Login: Tuesday, December 07, 2010 12:55 AM
Points: 771,
Visits: 504
|
|
| Excellent question. Defaults are always something to keep in mind and to avoid relying on, as they may change.
|
|
|
|
|
SSC-Enthusiastic
      
Group: General Forum Members
Last Login: 2 days ago @ 6:13 AM
Points: 134,
Visits: 617
|
|
|
|
|
|
SSCertifiable
       
Group: General Forum Members
Last Login: Today @ 3:35 PM
Points: 7,102,
Visits: 7,166
|
|
Good question. I got it wrong, because I didn't notice that the length wasn't specified. That will teach me not to skim read code when working out what it does (something I've often told others they must not do, but am still stupid enough to do it myself).
Tom Que conclure à la fin de tous mes longs propos? C'est que les préjugés sont la raison des sots. (Voltaire, 1756)
|
|
|
|
|
SSC Journeyman
      
Group: General Forum Members
Last Login: Tuesday, May 14, 2013 11:41 AM
Points: 77,
Visits: 218
|
|
Good question! I was shocked to see the four rows when I tried the query!
Leaving aside the issue of the COLLATION, I opted for the one row answer, because the first that came to mind was the default value of varchar in the CONVERT function, which is 30.
select convert (varchar, '123456789012345678901234567890123456789012345678901234567890 ')
|
|
|
|
|
Grasshopper
      
Group: General Forum Members
Last Login: Thursday, January 31, 2013 5:36 PM
Points: 10,
Visits: 10
|
|
| Because all colors are in proper case one can be led to believe that case sensitivity is a factor. To avoide this confusion it would be better to have all colors in lower or upper case.
|
|
|
|
|
SSC-Addicted
      
Group: General Forum Members
Last Login: Monday, May 20, 2013 9:43 AM
Points: 469,
Visits: 193
|
|
| Nice and interesting question.
|
|
|
|