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
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Store Procedures to get parameter in last day

Author  Topic 

friscapjtn
Starting Member

8 Posts

Posted - 2009-08-19 : 06:16:02
help me plis,

how to make a store procedure with input parameter = as of date from
the simple script in Juli 2009:

select top 25 vof_os_ar.*, gencustomer.sandiekonomi from vof_os_ar inner join
gencustomer on vof_os_ar.custid=gencustomer.custid
where asofdate='2009/07/31' and
LEFT(BATCHREF,4) IN ('Self','AKIT','SHIN','BNI/','RESO', 'VICTORIA LOAN')
order by osph desc

like passing parameter with month and year, I must find the last day of month and then I will must passing to store procedures that will I try to make.

Hmmm....

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2009-08-19 : 06:50:01
declare @month_year varchar(10)
set @month_year='july 2009'


select top 25 vof_os_ar.*, gencustomer.sandiekonomi from vof_os_ar inner join
gencustomer on vof_os_ar.custid=gencustomer.custid
where asofdate=dateadd(month,1,@month_year)-1 and
LEFT(BATCHREF,4) IN ('Self','AKIT','SHIN','BNI/','RESO', 'VICTORIA LOAN')
order by osph desc


Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

friscapjtn
Starting Member

8 Posts

Posted - 2009-08-19 : 06:56:58
@madhivanan


create procedure vof_generate
declare @month_year varchar(10)
set @month_year='july 2009'
as
select top 25 vof_os_ar.*, gencustomer.sandiekonomi from vof_os_ar inner join
gencustomer on vof_os_ar.custid=gencustomer.custid
where asofdate=dateadd(month,1,@month_year)-1 and
LEFT(BATCHREF,4) IN ('Self','AKIT','SHIN','BNI/','RESO', 'VICTORIA LOAN')
order by osph desc


are you mean that?
but I want passing parameter with other month and year not only july 2009.

Pliss help me



Hmmm....
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2009-08-19 : 07:28:38
[code]create procedure vof_generate
(
@month_year varchar(10)
)
as
select top 25 vof_os_ar.*, gencustomer.sandiekonomi from vof_os_ar inner join
gencustomer on vof_os_ar.custid=gencustomer.custid
where asofdate=dateadd(month,1,@month_year)-1 and
LEFT(BATCHREF,4) IN ('Self','AKIT','SHIN','BNI/','RESO', 'VICTORIA LOAN')
order by osph desc[/code]

GO



Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

friscapjtn
Starting Member

8 Posts

Posted - 2009-08-19 : 07:50:10
i'm sorry, but i didn't find the result when i execute them.
May be you can show me the result.


regards,


friscapjtn

Hmmm....
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2009-08-19 : 08:19:01
After creating the procedure, execute it

EXEC vof_generate 'july 2009'


Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -