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
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Search Producedure (with COALESCE)

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2001-02-15 : 12:52:17
Mikhail Goncharov writes "I was trying to use the same technique as the author in Dynamic Order By article to search some information in the members table using this statement (I was using dynamic SQL before)

Create Procedure Find_Members
@memberID varchar(16)=NULL,
@FName varchar(50)=NULL,
@LName varchar(50)=NULL,
@sortby tinyint=1
AS

select * from members
where memberID=coalesce(@memberID,'') and
fname=coalesce(@fname,'') and lname=coalesce(@lname,'')
order by CASE when @sortby=1 then fname
when @sortby=2 then lname
end desc


This statement is not finding any records all the time.

How I can make it to find matching records ?
(1 statement only)"
   

- Advertisement -