ms sql server 2005 - get results from #temp table

Posted on 2011-10-14
Last Modified: 2012-05-12
I am creating a sproc using #temp table and I want to see what is loaded into the #temp table before it is destroyed at the end

I try this to get the data to the results window:

--doesnt work...

select col1,col2,col3 into #temp_table (select...from....

select * from #temp_table

how can I print out  the data in the columns from the #temp_table to the results window when I run the code??
Question by:GlobaLevel
    LVL 69

    Expert Comment

    by:Éric Moreau
    I would surprised that "select * from #temp_table" is not working. Any error message? Can you show your SP?
    LVL 32

    Accepted Solution


    select * from #temp_table

    This should work unless there is actually no data in the temp table. Can you post the code for the stored procedure
    LVL 32

    Expert Comment

    If this is being run in code, as opposed to in SSMS or some similar tool, look at what is needed to return multiple recordsets.  Also in this case - is the method being used to execute the stored procedure prepared to receive a returned table

    If this is being run in a stored procedure.. I have no idea why it would not return the data.  Does the stored procedure already return a recordset?
    LVL 8

    Expert Comment

    by:Andrei Fomitchev
    Before delete #temp_table


    select * from #temp_table

    and run your stored procedure in SSMS.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    If you have heard of RFC822 date formats, they can be quite a challenge in SQL Server. RFC822 is an Internet standard format for email message headers, including all dates within those headers. The RFC822 protocols are available in detail at:   ht…
    In this article I will describe the Backup & Restore method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
    Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.
    Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    10 Experts available now in Live!

    Get 1:1 Help Now