select * from sys.objects where xtype='U' and name='yourtablename'
IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'tablename') AND type in (N'U')) print '已经创建' else print '没有创建'
--or if exists(select 1 from sys.objects where xtype='U' and name='yourtablename' 存在的处理 else 不存在的处理
select object_id('t_表名') -- 非空为存在
select object_id('t_表名') -- 非空为存在
if object_id('tb') is not null print '已经创建' else print '没有创建'
对于表的字段类型,你可以用下列语句执行一下,就知道了: select * from sys.columns不同数据类型,它的system_type_id不同.
提示: 消息 207,级别 16,状态 1,第 1 行 列名 'xtype' 无效。 什么意思
select case isnullable when 0 then '不可为空' else '可为空' end as '可否为空', type_name(xusertype) as '数据类型' from syscolumns where object_name(id) = 't_表名' and name = '列名'
写错了,是 select * from sysobjects where xtype='U' and name='yourtablename'
print '已经创建'
else
print '没有创建'
if exists(select 1 from sys.objects where xtype='U' and name='yourtablename'
存在的处理
else
不存在的处理
print '已经创建'
else
print '没有创建'
select * from sys.columns不同数据类型,它的system_type_id不同.
消息 207,级别 16,状态 1,第 1 行
列名 'xtype' 无效。
什么意思
type_name(xusertype) as '数据类型'
from syscolumns where object_name(id) = 't_表名' and name = '列名'
select * from sysobjects where xtype='U' and name='yourtablename'