在 SQL Server 2014 中找不到用户定义的数据类型“empnum" [英] Cannot find user defined datatype 'empnum' in SQL Server 2014

查看:61
本文介绍了在 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.

这篇关于在 SQL Server 2014 中找不到用户定义的数据类型“empnum"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆