如何在 SQL Server 数据库中列出用户定义的类型? [英] How do I list user defined types in a SQL Server database?
问题描述
我需要使用 CREATE TYPE
枚举在 SQL Server
数据库中创建的所有用户定义类型,和/或找出它们是否已经定义.>
对于表或存储过程,我会做这样的事情:
if exists (select * from dbo.sysobjects where name='foobar' and xtype='U')删除表 foobar
但是我找不到用户定义类型的等效项(或合适的替代方案)!我绝对在 sysobjects
中的任何地方都看不到它们.
有人能指教我吗?
类型和 UDT 不会出现在 sys.objects 中.您应该能够通过以下方式获得所需内容:
select * from sys.types其中 is_user_defined = 1
I need to enumerate all the user defined types created in a SQL Server
database with CREATE TYPE
, and/or find out whether they have already been defined.
With tables or stored procedures I'd do something like this:
if exists (select * from dbo.sysobjects where name='foobar' and xtype='U')
drop table foobar
However I can't find the equivalent (or a suitable alternative) for user defined types! I definitely can't see them anywhere in sysobjects
.
Can anyone enlighten me?
Types and UDTs don't appear in sys.objects. You should be able to get what you're looking for with the following:
select * from sys.types
where is_user_defined = 1
这篇关于如何在 SQL Server 数据库中列出用户定义的类型?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!