The other day I was creating a table to store some metadata. Since the metadata I was collecting (sys.databases.name for example) uses the datatype sysname I used the same datatype. In case you didn’t know sysname is an nvarchar(128) user defined datatype used in a number of the system views.
Anyway, I was a bit surprised (and later realized I probably shouldn’t be) that the default for sysname is to not allow nulls.
CREATE TABLE sysname_test (
Col1 sysname
,Col2 nvarchar(128)
);
GO
EXEC sp_help sysname_test;
GO
DROP TABLE sysname_test;
GO
Now you can override that if you need to, it’s just the default, but the final definition for sysname is going to be:
sysname := nvarchar(128) NOT NULL
Which you can see pretty easily by looking in the sys.types system view.
SELECT * FROM sys.types
WHERE NAME = 'sysname';