[dba-SQLServer]Help with stored procedure

Billy Pang tuxedo_man at hotmail.com
Wed Oct 15 13:53:07 CDT 2003


In a stored procedure report, how do I allow an optional filter for a select 
statement/

For example:

use pubs
go
CREATE PROCEDURE au_info @lastname varchar(40), @firstname varchar(20) AS
SELECT au_lname, au_fname
FROM authors
WHERE au_lname = @lastname and au_fname = @firstname
go
EXECUTE au_info @firstname = null, @lastname = 'Ringer'
GO
DROP PROCEDURE au_info

I want the stored procedure to return all records where last name is 
"ringer" (there should be two of them) but right now it returns nothing.

Thanks in advance,
Billy

_________________________________________________________________
MSN 8 helps eliminate e-mail viruses. Get 2 months FREE*.  
http://join.msn.com/?page=features/virus



More information about the dba-SQLServer mailing list