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
 General SQL Server Forums
 New to SQL Server Programming
 Regarding Fetching Data

Author  Topic 

mailtosaja
Starting Member

28 Posts

Posted - 2008-08-25 : 03:43:15
Hi,

create procedure test
@EmpID varchar(100),
@JoinData DateTime,
@EndDate DateTime
as


select * from Emp_Details where JoinDate between '7 Jun 2008' and
'8 Jun 2008' and (@empId is null or Emp_id=@EmpID)

.....
this is my sp..Here i got the correct out put...I would like to add some more Emp id in the condition,When @EmpID is null(for Example 101,103) ..If it is not null means we will match the condtion EmpID=@EmpId..if @empid is null means we will check with (101,103)
otherwise empid=@empId

How can i write the Query for that....

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-08-25 : 03:46:07
[code]create procedure test
@EmpID varchar(100),
@JoinData DateTime,
@EndDate DateTime
as


select * from Emp_Details where JoinDate between '7 Jun 2008' and
'8 Jun 2008' and
((@empId is null and Emp_id in (101,103,..))
or Emp_id=@EmpID)[/code]
Go to Top of Page
   

- Advertisement -