Delete constraint after taking its name

0

I'm running the following query to get the name of 2 constraints :

select TC.Constraint_Name from information_schema.table_constraints TC
inner join information_schema.constraint_column_usage CC on TC.Constraint_Name = CC.Constraint_Name
where TC.constraint_type = 'Unique' and CC.TABLE_NAME = 'NAVIO'
order by TC.Constraint_Name

How can I make a function to exclude each value that returns in this select?

    
asked by anonymous 16.10.2017 / 19:45

1 answer

0

Hello,

Here's an alternative to your case.

select 'ALTER TABLE ' + CC.TABLE_NAME + '  DROP [CONSTRAINT] '+ TC.Constraint_Name+' ; GO' 
  from information_schema.table_constraints TC
 inner join information_schema.constraint_column_usage CC on TC.Constraint_Name = CC.Constraint_Name
 where TC.constraint_type = 'Unique' and CC.TABLE_NAME = 'NAVIO'
 order by TC.Constraint_Name

See if it helps you, anything is just to return. With return you will have contraints "DROP"

    
16.10.2017 / 20:07