I would like to know why when I create a custom data type in SQL Server based on a non-zero integer and assign it a default value, I cannot get this value if it is not a table definition (only one declared variable ) Here is my code:
BEGIN TRAN; GO CREATE TYPE Province FROM INT NOT NULL; GO CREATE DEFAULT ProvinceDefault AS 4; GO EXEC sp_bindefault 'ProvinceDefault', 'Province'; GO DECLARE @Province Province; SELECT @Province; GO ROLLBACK TRAN;
It returns NULL
source share