I tried following query to check whether constraint exists for a table or not.
IF OBJECT_ID('SET_ADDED_TIME_AUTOMATICALLY') IS NOT NULL
ALTER TABLE HS_HR_PEA_EMPLOYEE DROP CONSTRAINT SET_ADDED_TIME_AUTOMATICALLY
Got this error.
Constraint 'SET_ADDED_TIME_AUTOMATICALLY' does not belong to table 'HS_HR_PEA_EMPLOYEE'
Then I tried to add the constraint to the table.
ALTER TABLE HS_HR_PEA_EMPLOYEE
ADD CONSTRAINT SET_ADDED_TIME_AUTOMATICALLY DEFAULT GETDATE() FOR JS_PICKED_TIME
Got this one.
There is already an object named 'SET_ADDED_TIME_AUTOMATICALLY' in the database.
What's wrong with the query. Do I have to mention table name with the schema?