Find out particular occurance of weekday in a month

The following function returns the Nth occurance of week day in a month IF EXISTS (SELECT 1 FROM INFORMATION_SCHEMA.ROUTINES WHERE ROUTINE_NAME =’GetNthWeekday’ AND ROUTINE_SCHEMA = ‘dbo’ AND ROUTINE_TYPE=’FUNCTION’)DROP FUNCTION dbo.GetNthWeekdayGOCREATE FUNCTION dbo.GetNthWeekday(@date datetime,–Any date of month under consideration@N int,– Nth…

Find identity columns in a database

Here’s a way to find out the identity columns in a db/table SQL 2000 SELECT c.TABLE_NAME ,c.COLUMN_NAMEFROM INFORMATION_SCHEMA.COLUMNS cWHERE COLUMNPROPERTY(OBJECT_ID(c.TABLE_NAME),c.COLUMN_NAME,’IsIdentity’) = 1 SQL 2005/2008 SELECT OBJECT_NAME(Object_Id) AS Table_name, Name AS COLUMN_NAME FROM sys.identity_columns for getting identity columns in table just…