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
 In SP

Author  Topic 

mailtosaja
Starting Member

28 Posts

Posted - 2008-08-05 : 08:28:04
Hi,
Empid Empname Empadd
----------------------------
1 Jess Chennai
1 Jess1 Chennai
1 Jess Chennai
1 NULL Chennai

I have above table with Data.Below one sp i was used..What i want is
user should pass the Empid and EmpName is optional..
I was execute the sp (test_1 1,null) .I didn't get the full data..if any body please tell me..
create procedure test_1
(
@empid as int,
@empname varchar(max)=null
)
as
BEGIN
select * from x
where Empid=@empid and (
(@empname is null and Empname=Empname)
or
(Empname=@empname)
)
END

Thanks & Regards,
S.Jess

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2008-08-05 : 08:33:50
create procedure test_1
(
@empid as int,
@empname varchar(max)=null
)
as
BEGIN
select * from x
where Empid=@empid and (@empname is null or Empname=@Empname)
END


Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

mailtosaja
Starting Member

28 Posts

Posted - 2008-08-05 : 09:03:36
Hi,
I got the answer man..thanks a lot....
Thanks & Regards,
S.Sajan
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2008-08-05 : 09:38:23
quote:
Originally posted by mailtosaja

Hi,
I got the answer man..thanks a lot....
Thanks & Regards,
S.Sajan


You are welcome

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -