I have created default
CREATE DEFAULT dbo.enviroment AS 'UAT'
I have created user defined type
CREATE TYPE [dbo].[Environment] FROM [varchar](50) NOT NULL
Then I have used it to define user defined type dbo.environment
(using Studio not SP so I see dbo.environment in input "default" but it can be done : sp_bindefault 'dbo.environment','dbo.environment'
)
Now I declare variable and select:
declare @env dbo.environment
SELECT @env as env
Result is NULL I would expect 'UAT'
How default should work? Am I doing sth wrong?
Making use of default is possible like in this code:
create table dbo.test (id int, env dbo.environment)
insert into test (id) values(1)
select * from test
but is it possible without a table? (with variable table is not possible as well :( )
I was thinking about providing semi global variable in this way.
SQL SERVER 2008 R2