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
 General SQL Server Forums
 New to SQL Server Programming
 How to return a 1 or true after an update in SP

Author  Topic 

insanepaul
Posting Yak Master

178 Posts

Posted - 2012-04-23 : 11:11:17
i cant seem to find out how to return a boolean true after a successful update:

ALTER PROCEDURE [dbo].[usp_COR_upd_tblCORPerson_DotMailerID]
(
@PersonId INT,
@DotMailerID INT
)
AS

-- Insert statements for procedure here
SET NOCOUNT ON


UPDATE dbo.tbl_COR_Person
SET DotMailerID = @DotMailerID
WHERE PersonId = @PersonId

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-04-23 : 11:16:53
just add a check like



ALTER PROCEDURE [dbo].[usp_COR_upd_tblCORPerson_DotMailerID]
(
@PersonId INT,
@DotMailerID INT
)
AS

-- Insert statements for procedure here
SET NOCOUNT ON


UPDATE dbo.tbl_COR_Person
SET DotMailerID = @DotMailerID
WHERE PersonId = @PersonId

IF @@ERROR =0
RETURN 1
ELSE
RETURN 0
GO


DECLARE @Ret int
EXEC @Ret= usp_COR_upd_tblCORPerson_DotMailerID value1,value2

IF @Rec=1
PRINT 'Update Success'
ELSE
PRINT 'Update Failure'


------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

insanepaul
Posting Yak Master

178 Posts

Posted - 2012-04-23 : 11:18:05
great thanks
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-04-23 : 11:22:02
welcome

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -