What are the benefits of storing a name as "sysname" instead of "nvarchar (128)"?

I want to create a table in which information about stored procedures will be stored. I need to save SP_Name. My original plan was to use SP_Name NVARCHAR(128) NOT NULL.

From the procedure, I will use the function OBJECT_NAME(@@PROCID)to get the value for the column SP_Name.

This technet does not contain much type information SYSNAME. What is the SYSNAME data type in SQL Server? the question only explains what it is, but it doesn’t work, the answer is almost 3 years, and Microsoft made many updates to SQL Server in 2012 and 2014.

Will I repeat any of the advantages of storing SP_Namein SYSNAMEover a column NVARCHAR(128)? Or should I avoid using proprietary data types that can be deleted or changed in a later version?

+3
source share
2 answers

It provides an abstraction that protects you from implementation details. The advantage is that if the definition changes in future versions, your code will work correctly.

sysnameused as equivalent varchar(30). If, say, SQL Server 2016 allows object identifiers to be 256 characters, you do not need to search and update all hard-coded 128.

, , /, .

+5

- SP_Name SYSNAME NVARCHAR (128)?

; , , , .

, ?

, , sql, .

, technet , , :

, , sysname SQL Server , .

0

All Articles