Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Build a function in SP to ask for date range

Author  Topic 

Pasi
Posting Yak Master

166 Posts

Posted - 2014-02-13 : 12:40:56
HI ,
I have a store procedure that populates my form with data. now I need to add a function in there to prompt for begin date and end date to pull information for the selected date range. is there such functionality? Please help.
Thanks,
Pasi

here is my SP:


ALTER PROCEDURE [dbo].[myprep]

AS
BEGIN
select distinct
p.last_name,
p.first_name,
person_nbr,
cpt4_code_id,
service_item_desc,
mstr_list_item_desc, group_name
--p.person_id

from person p
inner join person_payer pp on pp.person_id =p.person_id
inner join patient_ b on b.payerName= pp.payer_name
inner join mstr_lists ml on ml.mstr_list_item_desc= pp.payer_name
inner join patient_procedure d on d.person_id = pp.person_id
--inner join patient_procedure c on c.payer_id =pp.payer_id
where group_name= 'ACO'
and cpt4_code_id in('99238', '99239')
order by last_name Asc


SET NOCOUNT ON;



END

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2014-02-13 : 12:48:03
Not in SQL server
You should be doing the prompt part in front end using webforms

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2014-02-13 : 23:13:00
not possible in SQL.

The prompting should be from your front end client application. Then you change the stored procedure to pass in the begin & end date as a parameter

create procedure <procedure_name>
@begin_date date,
@end_date date




KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

Pasi
Posting Yak Master

166 Posts

Posted - 2014-02-14 : 16:49:35
Got it thnax. That's what I ended up doing.
Pasi
Go to Top of Page
   

- Advertisement -