Executing Queries by Fetching them from a textptr

  • Deal All,

    I am using a stored Procedure that reads text from a table using textptr and read text. The Data in the table is actually a Valid DML Query. I need to execute this query while residing within the stored procedure. How can this be done? Can any body Help Me

    Muhammad Asif

  • Put the query into a text object and look at sp_executesql and EXECUTE. However be aware there are some adminsitrative needs you will have to perform and you open yourself open to injection attacks thru this process.

  • Also be aware that neither of those will handle the TEXT datatype. What you might want to look into is the undocumented sp_execresultset...

    If you're using SQL Server 2005, lemme know because there's a couple of tricks that can easily be done there... 😉

    --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 3 posts - 1 through 2 (of 2 total)

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