troubleshooting Question

SQL Server 2005 Optional Parameteres To use it in WHERE conditions

Avatar of ali_alannah
ali_alannah asked on
Microsoft SQL ServerMicrosoft SQL Server 2005
6 Comments1 Solution826 ViewsLast Modified:
Hi Guys
I am trying to create stored procedure to use it for quering purposes , let take this example to show what i needd exactly
create stored procedure GetJVS
@Jv_id int
, @Jv_BK nvarchar(10)
,@Debit  int
,@Credit int
,EntryDAte smalldatetime
,Updateddate smalldatetime
Select * from jvs WHERE ............
I need the to Put the condition after Where as optional and if he didnt supply this is means it will not be in hte where condition
In other word
suppose this query
select * from jvs where jv_id=@jv_id and credit = @credit
so if i specify the a default value for parameter in stored procedure creationto be =NULL  the the stamenet it will be
Select * from jvs where jv_id=@jv_id and credit =9.00  and ,@Debit  int
=NULL  And EntryDAte  = NULL  AndUpdateddate = NULL
so this is not i need
what i need is
Select * from jvs where jv_id=@jv_id and credit =9.00  
and forget any parameter the user dont supply
so what i should do to get that
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 6 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 6 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros