Sunday, 24 February 2019

Sysname datatype in SQL Server

SYSNAME is a built-in data type limited to 128 Unicode characters, which is primarily used to store object names in SQL Server. It is basically the same as using nvarchar (128) NOT NULL. Although it is SQL Server data type we cannot use this data type to create a column with it. This data type is not listed in the data-type list which comes when creating tables via table designer. By Default, SYSNAME is NOT NULL. All data type are stored on SYS.TYPES table. See below.


2 comments:

  1. Erm. If you're using server version 2008 R2 or later, I think you'll see nvarchar(256) in the missing column from your screenshot named, max_length.

    ReplyDelete
    Replies
    1. di0, you'll see a max_length of 256, which is the max bytes of the value, not the max number of characters. Since unicode characters might need 2 bytes of storage per character, nvarchar(128) might need 256 bytes to hold 128 characters.

      Delete

If you have any doubt, please let me know.

Popular Posts