How to print message after Update command in Stored procedure...

  • Hi All,

    I have a simple SP to perform update operation . Once the update operation is complete, i want to print Message as " No. of rows updated in name1 table is __(count from previous update)__" ...

    Can anyone help me on this one??

    ALTER PROCEDURE [dbo].[Userupdate]

    @OldName varchar(256),

    @NewName varchar(256)

    AS

    Begin

    update master set name1=@Newname where cstatus='Y' and name1=@Oldname

    update master set name2=@Newname where cstatus='Y' and name2=@Oldname

    End

    Result should be :

    No. of rows updated in name1 table is 2.

    No. of rows updated in name2 table is 0.

  • Something like this?

    ALTER PROCEDURE [dbo].[Userupdate]

    @OldName varchar(256),

    @NewName varchar(256)

    AS

    Begin

    declare @rows varchar(38),

    @msg varchar(2000)

    update master set name1=@Newname where cstatus='Y' and name1=@Oldname

    set @rows = @@rowcount

    set @msg='No. of rows updated in name1 table is ' +@rows

    print @msg

    update master set name2=@Newname where cstatus='Y' and name2=@Oldname

    set @rows = @@rowcount

    set @msg='No. of rows updated in name2 table is ' +@rows

    print @msg

    End



    Lutz
    A pessimist is an optimist with experience.

    How to get fast answers to your question[/url]
    How to post performance related questions[/url]
    Links for Tally Table [/url] , Cross Tabs [/url] and Dynamic Cross Tabs [/url], Delimited Split Function[/url]

  • i think in your case this will work.

    Raiserror('message %s',0,1,@rowcount)with no wait.

    it will give u the message at the time of execution it self

    for more details follow the like

    http://www.mssqltips.com/tip.asp?tip=1660

  • Thank you All...

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply