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.
Author |
Topic |
rh_hosseiny
Starting Member
5 Posts |
Posted - 2011-06-16 : 03:34:40
|
Hi,I create a StoreProcedure in sqlserver 2008as fallowALTER PROCEDURE dbo.Patient_Search ( @UnitNumber int, @NamePatient nvarchar(20), @CodeShenasaeiBime int, @NationalCode int )AS select * From Tbl_Patient where (NationalCode=@NationalCode OR NationalCode is null And UnitNumber=@UnitNumber OR UnitNumber is null And CodeShenasaeiBime=@CodeShenasaeiBime OR CodeShenasaeiBime is null And NamePatient like N'%'+@NamePatient+'%' or NamePatient is null)but it dosent work.is there any one to help me? |
|
Lumbago
Norsk Yak Master
3271 Posts |
Posted - 2011-06-16 : 04:16:02
|
select * From Tbl_Patientwhere (NationalCode=@NationalCode OR @NationalCode is null)And (UnitNumber=@UnitNumber OR @UnitNumber is null)And (CodeShenasaeiBime=@CodeShenasaeiBime OR @CodeShenasaeiBime is null)And (NamePatient like N'%'+@NamePatient+'%' or @NamePatient is null)You should however read this first:http://sqlinthewild.co.za/index.php/2009/03/19/catch-all-queries/- LumbagoMy blog-> http://thefirstsql.com/2011/02/07/regular-expressions-advanced-string-matching-and-new-split-function-sql-server-2008-r2/ |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2011-06-16 : 04:17:30
|
quote: Originally posted by rh_hosseiny Hi,I create a StoreProcedure in sqlserver 2008as fallowALTER PROCEDURE dbo.Patient_Search ( @UnitNumber int, @NamePatient nvarchar(20), @CodeShenasaeiBime int, @NationalCode int )AS select * From Tbl_Patient where (NationalCode=@NationalCode OR @NationalCode is null And UnitNumber=@UnitNumber OR @UnitNumber is null And CodeShenasaeiBime=@CodeShenasaeiBime OR @CodeShenasaeiBime is null And NamePatient like N'%'+@NamePatient+'%' or @NamePatient is null)but it dosent work.is there any one to help me?
No, you're never too old to Yak'n'Roll if you're too young to die. |
|
|
Lumbago
Norsk Yak Master
3271 Posts |
Posted - 2011-06-16 : 04:45:26
|
- LumbagoMy blog-> http://thefirstsql.com/2011/02/07/regular-expressions-advanced-string-matching-and-new-split-function-sql-server-2008-r2/ |
|
|
rh_hosseiny
Starting Member
5 Posts |
Posted - 2011-06-16 : 06:47:00
|
Thank alot.but it dosn't work still.this storeprocedure just work for the first argument which is @NationalCode.another argument did'nt work |
|
|
|
|
|