sql server - SQL 2000/2005/2008 - Find Unique Constraint Name for a column -


i have table column needs data type upgrading. running alter script causes errors due unnamed unique constraint.

i need drop constraint unfortunately not know name. have script lists unique constraints on table need find out how go 1 step further , associate constraint names columns.

select * sysobjects sysobjects.xtype = 'uq' , sysobjects.parent_obj= object_id(n'users') 

this returns

uq__users__45f365d3 uq__users__46e78aoc 

i need know columns theses linked in order delete right one. need support sql 2000, 2005, , 2008.

any suggestions appreciated.

thanks ben

you should able use information_schema.constraint_column_usage establish this.

select     constraint_name      information_schema.constraint_column_usage      table_name = 'tablename'     , column_name = 'columnname' 

not whether view supported in sql 2000 though.


Comments

Popular posts from this blog

ruby - When to use an ORM (Sequel, Datamapper, AR, etc.) vs. pure SQL for querying -

php - PHPDoc: @return void necessary? -

c++ - Convert big endian to little endian when reading from a binary file -