DECLARE @StartDate DATETIME
SET @StartDate='01/01/2010'
;WITH CTE AS
(
SELECT @StartDate as dt, 1 as Id
UNION ALL
SELECT DATEADD(dd,1,dt),CTE.Id + 1
FROM CTE
WHERE Id <= 365
)
Insert Into HOLIDAY
([HOLIDAY_DATE],[SPECIFICATION])
Values
(
(select dt from CTE Where(DATEPART(dw,dt)=1 OR DATEPART(dw,dt)=7)),
(Select DATENAME(dw,dt)from CTE WHERE (DATEPART(dw,dt)=1 OR DATEPART(dw,dt)=7))
)OPTION (MAXRECURSION 0);
But i Got Some Error
Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression.
The statement has been terminated.
Arshad Ashra...
Member
620 Points
149 Posts
Re: Sql Query For Getting Sundays And Saturdays in a given Year
Apr 23, 2012 06:19 AM|LINK
My Query Given Below
But i Got Some Error