|
|
|
SSChampion
        
Group: General Forum Members
Last Login: Friday, May 18, 2007 3:36 PM
Points: 10,040,
Visits: 1
|
|
| Comments posted to this topic are about the Question of the Day for 01 Dec 2005 posted at http://www.sqlservercentral.com/testcenter/qod.asp?QuestionID=654.
|
|
|
|
|
Grasshopper
      
Group: General Forum Members
Last Login: Thursday, April 08, 2010 4:54 PM
Points: 23,
Visits: 3
|
|
The funny thing is that in
select cast('This is a test' as varchar)
the varchar size defaults to 30, so in this case the full string is returned.
|
|
|
|
|
SSCrazy
      
Group: General Forum Members
Last Login: Tuesday, June 11, 2013 6:18 AM
Points: 2,388,
Visits: 710
|
|
That's probably tomorrow's question.  I looked at the MSDN reference, and it had the following line: The SQL-2003 synonym for char is character. What is SQL-2003? Mattie
|
|
|
|
|
SSC Veteran
      
Group: General Forum Members
Last Login: Monday, October 10, 2011 2:00 PM
Points: 297,
Visits: 329
|
|
Yeah, I noticed that too. Probably what SQL - 2005 was supposed to be! I also saw a new feature that I think I'll really like Declare @i varchar(max) Gives you a rather large text store without the text datatype's limitations? Cool.
Student of SQL and Golf, Master of Neither
|
|
|
|
|
Hall of Fame
       
Group: General Forum Members
Last Login: Tuesday, June 11, 2013 10:47 AM
Points: 3,226,
Visits: 424
|
|
While it was correct, the answer wasn't complete. Per BOL, VARCHAR defaults to 1 when it's used in a data definition or variable declaration statement. BUT it defaults to 30 when used with CAST.
-SQLBill
|
|
|
|
|
SSC Veteran
      
Group: General Forum Members
Last Login: Monday, October 10, 2011 2:00 PM
Points: 297,
Visits: 329
|
|
Well, as long as we're being picky, it defaults to 50 when you're using EM to define a field too. But, if you take the question literally as presented, the answer was correct. And that's all that really counts for a test.
Student of SQL and Golf, Master of Neither
|
|
|
|
|
Hall of Fame
       
Group: General Forum Members
Last Login: Monday, July 30, 2012 10:42 AM
Points: 3,434,
Visits: 519
|
|
Hi, The BOL topic "Char and Varchar" says: ".....Remarks When n is not specified in a data definition or variable declaration statement, the default length is 1. When n is not specified with the CAST function, the default length is 30...." In the Enterprise Manager you do specify n. 50 is a suggested length. It does not let you to select nothing for n, posts a message that n must be from 1 to 8000. Enterprise Manager is a client application which may have any restrictions specified by its programmers (Microsoft in this case) where TSQL statements and its rules are applicable to server software SQL Server.
Regards, Yelena Varshal
|
|
|
|
|
SSC Veteran
      
Group: General Forum Members
Last Login: Saturday, March 07, 2009 11:43 AM
Points: 286,
Visits: 9
|
|
| In response to what is SQL 2003. That likely does not refer to SQL Server 2003, but, the ANSI SQL 2003 standard.
|
|
|
|
|
Ten Centuries
      
Group: General Forum Members
Last Login: Today @ 12:01 AM
Points: 1,127,
Visits: 1,275
|
|
nice and easy question....
|
|
|
|