Results 1 to 5 of 5
  1. #1
    Join Date
    Apr 2009
    Posts
    30

    Question Unanswered: Store Procedure query - help needed

    I'm using a MS SQL Serve 2008. My application has GUI. If I perform certain action from GUI then 16 tables are getting affected. After that I have to check manually if all the tables are updated or not and prepare a report as follows...

    =============
    Table | Has Entry
    =============
    ABC | Yes
    XYZ | No
    PQR | No
    BCF | Yes
    ==============
    So, I have decide to write a Stored Procedure(SP) for this, which will execute the query and if query returns an output then it will update a flag as Yes and if query doesn't return an output then it will update flag as No. But how can I come to know that query returned an output and I have to set the flag value as Yes.
    Last edited by shende.tejas; 05-25-10 at 07:38.

  2. #2
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    I'm afraid without a more specific question I can't give a more specific answer however you might find that the OUTPUT clause will be very useful.

  3. #3
    Join Date
    Apr 2009
    Posts
    30
    Hello Pootle,

    Can you please let me know, what part you wanna more specific ??


    EX.
    1. I have a stored procedure that affects 4 tables namely "ABC", "XYZ", "PQR", "BCF"
    2. The tables "ABC", and "BCF" have been updated.
    3. Tables "XYZ" and "PQR" are not updated.

    Now I would like to see the result of the SP as the following table:

    =============
    Table | Updated
    =============
    ABC | Yes
    XYZ | No
    PQR | No
    BCF | Yes
    ==============

    Thanks a lot.
    Last edited by shende.tejas; 05-25-10 at 07:51.

  4. #4
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    In that case an easier method is checking @@ROWCOUNT
    Code:
    UPDATE myTable
    SET myCol  = 'we love'
    WHERE myOtherCol = 'pootle'
    
    IF @@ROWCOUNT > 0--then rows in this table have been affected

  5. #5
    Join Date
    Apr 2009
    Posts
    30
    Hello pootle,

    Thank you for your reply. I have tried this and it works for me.

    Thanks once again.

    --Tejas

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •