Site Sponsored By: SQLDSC - SQL Server Desired State Configuration
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.
What is the correct way to do this?ALTER procedure Rpt_BookingsDetalBySlsSPLC( @BegOrderDate Datetime = null, @EndOrderDate Datetime = null, @SlsPerson nvarchar (8) = null)asselect * from BookingsDetailBySlswhere activity_date between isnull(@BegOrderDate,dbo.lowdate()) and isnull(@EndOrderDate,dbo.HighDate()) and TotalOrders <> '0'and case when @SlsPerson = 'lc' then slsman like 'la%' or slsman = 'fd'elseslsman = @SlsPerson
bklr
Master Smack Fu Yak Hacker
1693 Posts
Posted - 2010-03-05 : 02:16:46
try like this
select * from BookingsDetailBySlswhere activity_date between isnull(@BegOrderDate,dbo.lowdate()) and isnull(@EndOrderDate,dbo.HighDate())and TotalOrders <> '0'and( ( @SlsPerson = 'lc' AND ( slsman like 'la%' or slsman = 'fd' ) ) OR slsman = @SlsPerson)