Default Constraints

,

To Retreive List of Default Constraints from current database

/****** Object:  StoredProcedure [dbo].[usp_getDefaultConstraints]    Script Date: 04/20/2007 23:06:04 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[usp_getDefaultConstraints]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[usp_getDefaultConstraints]
GO
/*
Purpose	 		: To Retreive List of Default Constraints from current database
Created  Date	: 04/20/2007
Created  by		: Satyanarayana Bommidi
Parameters		: NO
	Input		: 
	Output		:	
EXEC			: EXEC usp_getDefaultConstraints 
*/
CREATE PROCEDURE usp_getDefaultConstraints
AS
BEGIN
	SELECT t.Name as Table_Name, c.Name as Column_Name, d.Name as Default_Constraints_Name, d.definition as Default_Value
	FROM sys.default_constraints d 
	LEFT JOIN sys.tables t ON d.parent_object_id = t.object_id
	LEFT JOIN sys.columns c ON t.object_id = c.object_id AND d.parent_column_id = c.column_id
END
GO

Rate

Share

Share

Rate