/*****************************************************************************
CLR SQL Server 2005
Description: List of all the Tuesdays this year (2007)
Author : Guillermo Julca
View Output
*****************************************************************************/
using System;
using System.Data;
using System.Data.SqlClient;
using System.Data.SqlTypes;
using Microsoft.SqlServer.Server;
public partial class
StoredProcedures
{
[Microsoft.SqlServer.Server.SqlProcedure]
public static void spListAllTuesdays()
{
DateTime NextDateTime;
DateTime StartDate;
StartDate = Convert.ToDateTime("01/01/2007 0:0:0");
NextDateTime = StartDate;
SqlContext.Pipe.Send("List of all the Tuesdays this
year \n");
SqlContext.Pipe.Send("------------------------------------------------------------------
\n");
while( NextDateTime.Year == StartDate.Year )
{
if (NextDateTime.DayOfWeek ==
DayOfWeek.Tuesday)
{
string strDate;
strDate = Convert.ToString(NextDateTime);
SqlContext.Pipe.Send(strDate);
}
NextDateTime = NextDateTime.AddDays(1);
}
}
};
View Output
//---------------------------------------------------------------------------
Copyright © 2002
GJ
GUILLERMO JULCA