SQL 判断表或字段是否存在
tPlayer 表名
sName 字段名
if object_id(N'tPlayer',N'U') is null print '不存在' else print '存在'
IF NOT EXISTS(SELECT * FROM syscolumns WHERE [ID] = object_id(N'tPlayer') AND [NAME] = N'sName') print '不存在' else print '存在'
tPlayer 表名
sName 字段名
if object_id(N'tPlayer',N'U') is null print '不存在' else print '存在'
IF NOT EXISTS(SELECT * FROM syscolumns WHERE [ID] = object_id(N'tPlayer') AND [NAME] = N'sName') print '不存在' else print '存在'