SQL语句判断某个表是否存在某个字段
IF NOT EXISTS(
SELECT *
FROM syscolumns
WHERE id = ( SELECT id
FROM sysobjects
WHERE name = 'dnt_photos'
)
AND name = 'width')
ALTER TABLE [dnt_photos] ADD [width] [int] DEFAULT(0) NOT NULL ;
SELECT *
FROM syscolumns
WHERE id = ( SELECT id
FROM sysobjects
WHERE name = 'dnt_photos'
)
AND name = 'width')
ALTER TABLE [dnt_photos] ADD [width] [int] DEFAULT(0) NOT NULL ;