SQL Server Integration Services
A Microsoft platform for building enterprise-level data integration and data transformations solutions.
2,702 questions
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
I need a IF Statement to check and run SQL Query
alter table [ReportableResults] add constraint
Unique_ReportableResults_ReportableResultCode_IsCalculated unique (ReportableResultCode, IsCalculated);
Above Code is Working Fine.....But I dont want to run Everytime...
I want to check if its already altered then not need to run the Above Query.
The following code will create the constraint if there is no object named Unique_ReportableResults_ReportableResultCode_IsCalculated, but if it already exists, the code will do nothing.
If Not Exists(Select * From sys.objects Where Name = 'Unique_ReportableResults_ReportableResultCode_IsCalculated')
alter table [ReportableResults] add constraint
Unique_ReportableResults_ReportableResultCode_IsCalculated unique (ReportableResultCode, IsCalculated);
Tom