• dob111283 (6/17/2013)


    Wow Sean thank you so much for that quick response. I understand what you wrote except, "return Sometable". Since I'm querying a stored procedure dbo.PEX_ClearedTransactions, how would I call that?

    You have me at a disadvantage here. It seems you have some code that is already in use and some other that you are writing. The problem from my end is that I have no idea what is already in use, what the tables are, what procs you have in place etc. The reason I said SomeTable is because I have no idea where that data would come from.

    If you already have a proc that you want to use you need to capture those details into a table.

    I can give you an example of how you can capture the results of a stored proc into a temp table. Keep in mind that this assumes your proc ONLY returns a single result set. If it returns multiple result sets this becomes a bit more complicated.

    First we need a stored proc.

    create proc CaptureExample

    as

    select top 5 name, object_id, type, type_desc from sys.objects

    This can represent your existing proc. Ignore that there is a top without an order by, this may very well return different results each time you run it (this is a topic for another day).

    Now you want to capture those results into a table (a temp table in my example).

    create table #MyCapture

    (

    name sysname,

    object_id int,

    type char(2),

    type_desc nvarchar(60)

    )

    insert #MyCapture

    exec CaptureExample

    select * from #MyCapture

    Does that help?

    _______________________________________________________________

    Need help? Help us help you.

    Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.

    Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.

    Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
    Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
    Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
    Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/