34,590
社区成员
发帖
与我相关
我的任务
分享
if not exists(select name from sysobjects where name=''+@name+'' and type='u')
begin
-- 创建
end
sysobjects 中有二个表示对象类型的字段(type,xtype)。
type是在 SQL Server 6.0 就有的,xtype在 SQL Server 7.0 才出现的。
对比了一下 type 与 xtype,有一些不同:
type:
K = PRIMARY KEY 或 UNIQUE 约束
R = 规则
xtype:
PK = PRIMARY KEY 约束(类型是 K)
UQ = UNIQUE 约束(类型是 K)
type 是为了与过去的版本相兼容而存在的,SQL Server7.0 之后用 xtype 就可以了。