Grant permissions for user defined data type to the appropriate users as suggested in the Cause section. You can also workaround the problem by using one of the following methods.
Method 1: Grant REFERENCES permission to the public user in the model database.
For example:
- CREATE TYPE dbo.udt_money FROM varchar(11) NOT NULL ;
go
GRANT REFERENCES ON TYPE::dbo.udt_money TO public
NOTE: Before using this method carefully evaluate the security implications since this permission gets carried over to every new database.
Method 2: If you do not want every new database to retain the definition and permissions for this user- defined data type, you can use a startup stored procedure to create and assign the appropriate permissions only in tempdb database.
For example:
USE mastergoCREATE PROCEDURE setup_udt_in_tempdbASEXEC ( 'USE tempdb;CREATE TYPE dbo.udt_money FROM varchar(11) NOT NULL;
GRANT REFERENCES ON TYPE::dbo.udt_money TO public;')
goEXEC sp_procoption 'setup_udt_in_tempdb' , 'startup' , 'on'go
Method 3: Instead of using temporary tables, consider using table variables when you need to reference user-defined data types for temporary storage needs. For table variables to reference user-defined data types, you do not need to explicitly grant permissions for the user-defined data type.