我想要删除某个字段,sql语句如下
IF EXISTS(select ObjectProperty(Object_ID( 'students'),'IsUserTable')) ALTER TABLE students DROP COLUMN status
但这个语句只能判断表是否存在,并未判断表下面的字段是否存在.结果导致我在执行批量语句的时候总是中断.如何在以上语句中在加入字段是否存在的判断呢?
------解决思路----------------------
IF EXISTS(select * from sys.tables where name ='students') and
exists(select * from sys.columns where object_id = object_id('students') and name = 'status')
ALTER TABLE students DROP COLUMN status