I have a stored procedure that I want to pass a Crystal parameter, SalonID into @SalonID, as well as the result of a formula into @Inputdate. The stored procedure creates 12 rows of data, which I then need to pass the availableDays back into the Crystal report and to be honest, I have no idea where to start! Could someone please point me in the right direction? The stored procedure is as below!
Mant thanks
Steve
USE [Snip-IT]
GO
/****** Object: StoredProcedure [dbo].[GetMonthlyAvail] Script Date: 05/11/2015 14:03:27 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[GetMonthlyAvail]
@SalonID int,
@InputDate date
AS
BEGIN
SET NOCOUNT ON;
; With Calendar As
(
Select DateAdd(Day, Number, @InputDate) As WorkDay,
DatePart(Weekday, DateAdd(Day, Number, @InputDate)) As DayId
From Master..spt_values
Where Type = 'P'
And number < 366
)
Select Top 12
Year(Calendar.WorkDay) As WorkYear,
Month(Calendar.Workday) As WorkMonth,
Count(*) As WorkingDays,
Count(BankHoliday) As BankHolidays,
Count(*) - Count(BankHoliday) As AvailableDays
From Calendar
Inner Join salonOpening
On Calendar.DayId = salonOpening.Day
Left Join PublicHolidays
On Calendar.Workday = PublicHolidays.BankHoliday
where SalonOpening.SalonID = @SalonID
Group By Year(Calendar.WorkDay), Month(Calendar.Workday)
Order By WorkYear, WorkMonth
END
Mant thanks
Steve
USE [Snip-IT]
GO
/****** Object: StoredProcedure [dbo].[GetMonthlyAvail] Script Date: 05/11/2015 14:03:27 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[GetMonthlyAvail]
@SalonID int,
@InputDate date
AS
BEGIN
SET NOCOUNT ON;
; With Calendar As
(
Select DateAdd(Day, Number, @InputDate) As WorkDay,
DatePart(Weekday, DateAdd(Day, Number, @InputDate)) As DayId
From Master..spt_values
Where Type = 'P'
And number < 366
)
Select Top 12
Year(Calendar.WorkDay) As WorkYear,
Month(Calendar.Workday) As WorkMonth,
Count(*) As WorkingDays,
Count(BankHoliday) As BankHolidays,
Count(*) - Count(BankHoliday) As AvailableDays
From Calendar
Inner Join salonOpening
On Calendar.DayId = salonOpening.Day
Left Join PublicHolidays
On Calendar.Workday = PublicHolidays.BankHoliday
where SalonOpening.SalonID = @SalonID
Group By Year(Calendar.WorkDay), Month(Calendar.Workday)
Order By WorkYear, WorkMonth
END