Geting the Values of SQL Results. is it possible even sp_executeSQL

  • Hi All,

    I am thinking of running some set of SQL commands, but as these includes a series of checks, I am thinking of possibly creating a stored procedure that will run these checks and email me the results.

    I am looking at various options, first of all is it possible to use sp_executesql to save the results of a query into another parameter ?

    Another way to get the results of queries, is to put this in a job and allow it to spool the results in a file using SQL agent.

    Is there another way to trap sql query results ?

    Thanks in advance.

  • Wouldn't INSERT/EXEC do the job you're looking for?

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • Hi,

    I didnt quite get the insert/exec idea, do you mean save the results in a table ?

    The problem is the results that I expect back can be in different formats.

    Thanks

  • Yes... the INSERT/EXEC would be used to save the results in a table. If you get different results, use more than 1 table... nothing wrong with that.

    Of course, you can also do things like making a view instead of a sproc depending on the nature of what you're trying to return. Also, a well designed table-valued function could do the trick. Neither of those methods will help with an existing sproc, though.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

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

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