Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Stored procedure, default value problem 1

Status
Not open for further replies.

mrdance

Programmer
Apr 17, 2001
308
SE
I have the default procedure below. I would like to return 0 if the sql can't find any voucherkey = @key.

How do I do that? Thanks!

CREATE PROCEDURE usp_verifyvoucherkey
(@key varchar(8))
AS
DECLARE @id int
SET @id = (
SELECT isvalid
FROM voucherkeys
WHERE voucherkey = @key)
RETURN @id
GO

--- neteject.com - Internet Solutions ---
 
Code:
CREATE PROCEDURE usp_verifyvoucherkey
  @key varchar(8)
AS

DECLARE @id int

SELECT @id = isvalid
FROM voucherkeys
WHERE voucherkey = @key

RETURN ISNULL(@id, 0)
GO

--James
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top