Hi, I want to check whether a particular column exist or not in a given table. This i want to check before dropping the column so no error comes if column is not present. So please can anybody tell me how i do this? Exmple: --How to do: check if column exist -- if exist ALTER table table_name DROP COLUMN column_name
Next time search the web before posting here IF NOT EXISTS (SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = ‘TEST’ AND COLUMN_NAME = ‘TEST_DATE’) BEGIN ALTER TABLE TEST ADD TEST_DATE DATETIME END Code (markup):