在 SQL Server 2014 中找不到用户定义的数据类型“empnum"
当我在 SQL Server 2014 中运行以下查询来创建临时表时:
When I run the following query in SQL Server 2014 to create a temporary table:
CREATE TABLE #temp
(
location char(16) null,
location_desc varchar(25) null,
Emp_Num EMPNUM null
)
我收到错误:
找不到数据类型 empnum.
Cannot find the data type empnum.
empnum
是用户定义的数据类型.但相同的用户定义数据类型在其他存储过程中也能正常工作.
empnum
is a user-defined data type. But the same user-defined data type is working fine in other stored procedures.
为什么我会收到此错误?
Why am I receiving this error?
如果使用 tempdb,则需要在 model
数据库中定义类型,因为类型处于 db 级别.如果已经为 model
定义了类型,那么如果 model
db 没有被赋予 db_ddladmin
角色,您可能仍然存在权限问题.
If using the tempdb, you need to define the type in the model
database since types are at the db level. If the type has been defined for the model
then you may still have permissions issues if the model
db hasn't been given the db_ddladmin
role.
model
db 是所有新 db 的模板,tempdb
在重新启动之间不会持续存在,每次启动时都会创建新的.
The model
db is a template for all new db's, tempdb
does not persist between restarts, it is created new each startup.