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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

TESTING STORED PROCEDURE

Status
Not open for further replies.

itsmarkdavies

Programmer
May 22, 2001
87
GB
I am running this procedure on SQL Server 2000 and would like some help on how to force an error to occur. The procedure text is as follows :-

CREATE PROCEDURE UpdateSalaries @RESULT CHAR(1) OUTPUT

AS

BEGIN TRAN

UPDATE PERSON
SET SALARY = 15000
FROM PERSON
WHERE DEPTID = 'WH'

IF @@ERROR <> 0
BEGIN
ROLLBACK TRAN
SELECT @RESULT = 'N'
PRINT @RESULT
RETURN
END

ELSE
BEGIN
SELECT @RESULT = 'Y'
PRINT @RESULT
END

COMMIT TRAN

GO

What I want to do is deliberatly make it error and return a value of 'N'.

Any help greatly appreciated.
 
Hi,

RAISERROR ('N', 16, 1) is the answer.

With this you may generate a error with 'N' value.
The other parameters are severity, state...
For detailed information on parameters you may consult BOL.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top