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
 SQL Server Development (2000)
 null values in sp and how to use a if/then

Author  Topic 

genic
Yak Posting Veteran

57 Posts

Posted - 2001-04-16 : 14:49:48
ok, i do not want to create 6 store procedures for each case that i am going to have. i would like to have just one......here is an example of one sp that i am using.

Alter Procedure sp_selectAllocatedHours_otd_date
@date1 varchar(255),
@date2 varchar(255),
@profileorg varchar(255),
@profiledept varchar(255),
@profileteam varchar(255)
As

select sum(convert(decimal(10,4), b.hours)) as totalTime from profile as a
inner join projecttime as b on (b.profileemail = a.profileemail)
where b.workdate between @date1 and @date2
and a.profile_org = @profileorg
and a.profile_dept = @profiledept
and a.profile_team = @profileteam

return

now if @date1 and @date2 are null i would like to take out the where clause and do
where a.profile_org = @profileorg ...etc...

ALSO

if @profileteam is null, i would like to exclude it from the query. same with @profiledept and @profileorg.

anyone help with this? thank you

   

- Advertisement -