﻿<?xml version='1.0' encoding='UTF-8'?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>SQLServerCentral / SQL Server 2008 / T-SQL (SS2K8)  / how to find duplicate default constraints in sql server / Latest Posts</title><generator>InstantForum.NET v2.9.0</generator><description>SQLServerCentral</description><link>http://www.sqlservercentral.com/Forums/</link><webMaster>notifications@sqlservercentral.com</webMaster><lastBuildDate>Sun, 19 May 2013 08:39:07 GMT</lastBuildDate><ttl>20</ttl><item><title>RE: how to find duplicate default constraints in sql server</title><link>http://www.sqlservercentral.com/Forums/Topic1360200-392-1.aspx</link><description>I have to agree with NOT A DBA in that your question is worded strangely and his answer is basically correct.I suspect you may be looking for something else, namely columns that appear like-named in different tables and have the same default values, but applied through a different DEFAULT constraint.This query probably will help to get you started, if this is what you seek:[code="sql"]SELECT TABLE_NAME=b.name, COLUMN_NAME=a.name, CONSTRAINT_NAME=c.name, d.COLUMN_DEFAULT FROM sys.all_columns a  INNER JOIN sys.tables b      ON a.object_id = b.object_id INNER JOIN sys.default_constraints c     ON a.default_object_id = c.object_id INNER JOIN information_schema.columns d    ON b.name = d.TABLE_NAME AND a.name = d.COLUMN_NAMEWHERE c.type_desc = 'DEFAULT_CONSTRAINT'[/code]It lists all columns from all tables that have a DEFAULT CONSTRAINT, along with the DEFAULT CONSTRAINT name and the default value it assigns.</description><pubDate>Mon, 17 Sep 2012 23:38:48 GMT</pubDate><dc:creator>dwain.c</dc:creator></item><item><title>RE: how to find duplicate default constraints in sql server</title><link>http://www.sqlservercentral.com/Forums/Topic1360200-392-1.aspx</link><description>[quote][b]achtro (9/17/2012)[/b][hr]how to find duplicate default constraints in a table ,example DF_abc1 is a default constraint FOR column Effective date and again DF_efg1 is also a default constraint FOR same column Effective date,Now i have a scenario where i  want to find the all duplicate default constraints on all the tables in a database, does anybody have any script for this .thanks[/quote]Perhaps your question is worded strangely, but you can't have duplicate default constraints for a column in a table. So you wouldn't need to look for duplicates.If you're looking for default constraints with the same name across a number of tables then sqlnaive's answer is what you want.</description><pubDate>Mon, 17 Sep 2012 15:14:06 GMT</pubDate><dc:creator>Not A DBA</dc:creator></item><item><title>RE: how to find duplicate default constraints in sql server</title><link>http://www.sqlservercentral.com/Forums/Topic1360200-392-1.aspx</link><description>Check this query:SELECT CONSTRAINT_NAME, COUNT(*) FROM INFORMATION_SCHEMA.CONSTRAINT_TABLE_USAGEGROUP BY CONSTRAINT_NAMEHAVING COUNT(*) &amp;gt; 1</description><pubDate>Mon, 17 Sep 2012 08:33:39 GMT</pubDate><dc:creator>sqlnaive</dc:creator></item><item><title>how to find duplicate default constraints in sql server</title><link>http://www.sqlservercentral.com/Forums/Topic1360200-392-1.aspx</link><description>how to find duplicate default constraints in a table ,example DF_abc1 is a default constraint FOR column Effective date and again DF_efg1 is also a default constraint FOR same column Effective date,Now i have a scenario where i  want to find the all duplicate default constraints on all the tables in a database, does anybody have any script for this .thanks</description><pubDate>Mon, 17 Sep 2012 07:37:31 GMT</pubDate><dc:creator>achtro</dc:creator></item></channel></rss>