Posted by SQL on 03/07/06 22:26
optional parameters have to be at the end of a stored proc
CREATE PROCEDURE get_sales_for_title
@something int,
@title varchar(80) = NULL
AS
-- Validate the @title parameter.
IF @title IS NULL
BEGIN
print 'do something here'
END
ELSE
BEGIN
print 'do something else here'
END
now you can call this proc like this
exec get_sales_for_title 1
or like this
exec get_sales_for_title 1,2
you will see that the print statement will be different for the 2 calls
http://sqlservercode.blogspot.com/
[Back to original message]
|