?
Solved

Date parameter

Posted on 2007-08-02
2
Medium Priority
?
217 Views
Last Modified: 2010-03-19
How would I add parameters to this stored proc for user to select Cal Year/Month instead of it being hardcoded???

CREATE Procedure dbo.sp_AttriHeadcnt
AS
SELECT BLC, sum(Headcount),[Cal Year/Month], @ [Cal Year/Month]
FROM dbo.Attrition
WHERE ((right([Cal Year/Month], 4)*100) + left([Cal Year/Month], 2)) between 200612 and 200706
GROUP BY BLC,[Cal Year/Month]
0
Comment
Question by:LiCann
2 Comments
 
LVL 15

Accepted Solution

by:
derekkromm earned 1000 total points
ID: 19620084
CREATE Procedure dbo.sp_AttriHeadcnt(@start varchar(6), @end varchar(6))
AS
SELECT BLC, sum(Headcount),[Cal Year/Month], @ [Cal Year/Month]
FROM dbo.Attrition
WHERE ((right([Cal Year/Month], 4)*100) + left([Cal Year/Month], 2)) between @start and @end
GROUP BY BLC,[Cal Year/Month]
0
 

Author Comment

by:LiCann
ID: 19620210
thanks!
0

Featured Post

Veeam and MySQL: How to Perform Backup & Recovery

MySQL and the MariaDB variant are among the most used databases in Linux environments, and many critical applications support their data on them. Watch this recorded webinar to find out how Veeam Backup & Replication allows you to get consistent backups of MySQL databases.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It is possible to export the data of a SQL Table in SSMS and generate INSERT statements. It's neatly tucked away in the generate scripts option of a database.
One of the most important things in an application is the query performance. This article intends to give you good tips to improve the performance of your queries.
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question