declare @date datetime
declare @dateStart datetime
declare @dateEnd datetime
declare @iCount int
set @iCount =1
set @dateStart='01-01-2007'
set @date=dateadd(day,1,@dateStart)
set @dateEnd='12-12-2007'
while (@date<=@dateEnd )
begin ;
if( DATENAME (weekday ,@date) = 'Sunday')select @date ;
set @date=dateadd(day,@iCount,@dateStart);
set @iCount=@iCount+1;
end;
declare @dateStart datetime
declare @dateEnd datetime
declare @iCount int
set @iCount =1
set @dateStart='01-01-2007'
set @date=dateadd(day,1,@dateStart)
set @dateEnd='12-12-2007'
while (@date<=@dateEnd )
begin ;
if( DATENAME (weekday ,@date) = 'Sunday')select @date ;
set @date=dateadd(day,@iCount,@dateStart);
set @iCount=@iCount+1;
end;