|
|
|
Say Hey Kid
      
Group: General Forum Members
Last Login: Monday, March 11, 2013 4:12 AM
Points: 664,
Visits: 138
|
|
|
|
|
|
Mr or Mrs. 500
      
Group: General Forum Members
Last Login: Wednesday, April 03, 2013 10:05 PM
Points: 584,
Visits: 1,571
|
|
Very nifty datatype to know if you ever need to store an object name.
S.
|
|
|
|
|
Ten Centuries
      
Group: General Forum Members
Last Login: Tuesday, May 07, 2013 12:02 PM
Points: 1,058,
Visits: 2,574
|
|
Fal (2/11/2010) Very nifty datatype to know if you ever need to store an object name.
S.
Indeed, but what I don't get is that about 33% of respondents think it is a function or variable! I mean, this is something as basic to know as a varchar or int.....
_______________________________________________________________________ For better assistance in answering your questions, click here
|
|
|
|
|
SSC-Addicted
      
Group: General Forum Members
Last Login: Tuesday, October 16, 2012 4:11 PM
Points: 449,
Visits: 168
|
|
If not for the fact that for the last week or so I've been messing with sp_Tables_ex and sp_columns_ex on Linked Oracle servers, I wouldn't have known about sysname either. For those like me still learning, i wouldn't say it was an obvious choice.
The distance between genius and insanity is measured only by success.
|
|
|
|
|
Ten Centuries
      
Group: General Forum Members
Last Login: Tuesday, May 07, 2013 12:02 PM
Points: 1,058,
Visits: 2,574
|
|
Brnbngls (2/12/2010) If not for the fact that for the last week or so I've been messing with sp_Tables_ex and sp_columns_ex on Linked Oracle servers, I wouldn't have known about sysname either. For those like me still learning, i wouldn't say it was an obvious choice.
didn't mean to come across like that. sysname is mentioned in many samples. Usually the proportion of correct answers vs wrong ones in the QotD is better (unless the question is flawed of course)... The idea is to learn from these QotD, and everyone does;) Cheers
_______________________________________________________________________ For better assistance in answering your questions, click here
|
|
|
|
|
SSCoach
         
Group: General Forum Members
Last Login: Monday, May 20, 2013 1:07 PM
Points: 18,733,
Visits: 12,332
|
|
|
|
|
|
SSCommitted
      
Group: General Forum Members
Last Login: 2 days ago @ 10:53 AM
Points: 1,662,
Visits: 1,709
|
|
This datatype has an interesting twist to it. If you have a database with case-sensitive collation, such as, for example SQL_Latin1_General_CP1_CS_AS then the following line of code will produce error:
declare @v sysName; This is because in databases with case-sensitive collations the sysname will only be recognized if it is spelled in lower case :)
declare @v sysname; will be parsed just fine regardless of case sensitivity.
Oleg
|
|
|
|
|
UDP Broadcaster
      
Group: General Forum Members
Last Login: Wednesday, April 17, 2013 10:57 PM
Points: 1,491,
Visits: 3,008
|
|
Richard M. (2/12/2010) ... Usually the proportion of correct answers vs wrong ones in the QotD is better (unless the question is flawed of course)...
or the answer cannot be determined by simply copying/pasting a script and running it in SSMS. 
This QOD did bring my attention to a new (to me) data type, one not listed in the main list of data types on my SQL 2005 BOL. Yes, I got it right, but the answer "function" did tempt me as "sysname" is also documented as a .NET property of the DataType class, so I understand why some respondents would have chosen that answer.
|
|
|
|
|
SSChampion
        
Group: General Forum Members
Last Login: Yesterday @ 8:43 PM
Points: 10,989,
Visits: 10,533
|
|
It seems odd to me that type names must be lower cased in a case-sensitive database. Also the case with hiercarchyid in SQL 2008. Am I the only one that prefers to upper case my types?
Paul White SQL Server MVP SQLblog.com @SQL_Kiwi
|
|
|
|
|
Hall of Fame
       
Group: General Forum Members
Last Login: Today @ 12:38 AM
Points: 3,190,
Visits: 4,148
|
|
Paul White NZ (3/30/2010) It seems odd to me that type names must be lower cased in a case-sensitive database. It's not true (or I don't understand what you mean). The names of system data types (except 'sysname') may be written in whatever case you want. The names of user data types (plus 'sysname') must be written in the same case as they are defined in the database.
DECLARE @1 Int, @2 int, @3 INT -- works fine in a case-sensitive DB GO CREATE TYPE MyAwesomeType FROM VARCHAR(30) GO DECLARE @1 MyAwesomeType -- works fine GO DECLARE @1 myAwesomeType -- fails in a case-sensitive DB GO DROP TYPE MyAwesomeType
SQL Server considers 'sysname' as a user data type and a system data type at the same time. Here is a script which confirms it:
SELECT name, system_type_id, user_type_id, is_user_defined FROM sys.types WHERE name = 'sysname'
-- name system_type_id user_type_id is_user_defined -- ---------- -------------- ------------ --------------- -- sysname 231 256 0
And here is a quote from BOL (http://msdn.microsoft.com/en-us/library/ms188021.aspx):
For system data types, user_type_id = system_type_id ... is_user_defined 1 = User-defined type. 0 = SQL Server system data type.
Sysname has system_type_id = 231, which means 'nvarchar'. Looks like sysname is created by the statement 'CREATE TYPE sysname FROM nvarchar(128)'.
Paul White NZ (3/30/2010) Am I the only one that prefers to upper case my types? It depends on what you call 'my types' For 'standard data types in my code', I prefer upper case (INT, VARCHAR, SYSNAME etc.). For 'data types defined by me' (which is equivalent to 'CLR data types' in my case), I prefer Pascal case (ParameterSet, VarArray etc.).
|
|
|
|