I am running SQL Server 2000. I need a stored procedure that defaults to the current period when no period is entered. The following select statement works correctly...
select *
from journal
where entityid='AIRLIN' AND (PERIOD=CAST(DatePart(YYYY,GetDate())AS varchar) + '02')
...but when I try to incorporated it into a stored procedure,(below) it doesn't work. Can anyone see the mistake in my logic?
ALTER Procedure sp_viiGetCashFlowAccounts
@BuildingID char(6) = 'AIRLIN',
@StartDate char(6) = (CAST(DatePart(YYYY,GetDate())AS varchar) + '01'),
@EndDate char(6) = CAST(DatePart(YYYY,GetDate())AS varchar) + '12')
AS
SELECT PERIOD,ACCTNUM,AMT,BASIS,STATUS
FROM journal
WHERE entityid=@BuildingID AND (Period>=@StartDate AND Period <= @EndDate)
GO
Thank You
select *
from journal
where entityid='AIRLIN' AND (PERIOD=CAST(DatePart(YYYY,GetDate())AS varchar) + '02')
...but when I try to incorporated it into a stored procedure,(below) it doesn't work. Can anyone see the mistake in my logic?
ALTER Procedure sp_viiGetCashFlowAccounts
@BuildingID char(6) = 'AIRLIN',
@StartDate char(6) = (CAST(DatePart(YYYY,GetDate())AS varchar) + '01'),
@EndDate char(6) = CAST(DatePart(YYYY,GetDate())AS varchar) + '12')
AS
SELECT PERIOD,ACCTNUM,AMT,BASIS,STATUS
FROM journal
WHERE entityid=@BuildingID AND (Period>=@StartDate AND Period <= @EndDate)
GO
Thank You