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)
 Dynamic Searches

Author  Topic 

william
Starting Member

8 Posts

Posted - 2001-06-21 : 22:27:47
Can anyone tell me if this is an efficient way of doing dynamic searches? I find it a good alternative to Dynamic SQL and quite simple...

CREATE PROCEDURE uspSearch

@Firstname varchar(50) = NULL,
@Lastname varchar(50) = NULL

AS
SET NOCOUNT ON

SELECT * FROM utPeople
WHERE ( @Firstname IS NULL OR FirstName = @Firstname ) AND ( @Lastname IS NULL OR LastName = @LastName )

   

- Advertisement -