[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

ms sql server 2005 - get results from #temp table

Posted on 2011-10-14
4
Medium Priority
?
292 Views
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:
PRINT #TEMP_TABLE

--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??
0
Comment
Question by:GlobaLevel
4 Comments
 
LVL 70

Expert Comment

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

Accepted Solution

by:
Ephraim Wangoya earned 2000 total points
ID: 36970230

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
0
 
LVL 32

Expert Comment

by:Brendt Hess
ID: 36970235
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?
0
 
LVL 8

Expert Comment

by:Andrei Fomitchev
ID: 36972304
Before delete #temp_table

put

select * from #temp_table

and run your stored procedure in SSMS.
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Windocks is an independent port of Docker's open source to Windows.   This article introduces the use of SQL Server in containers, with integrated support of SQL Server database cloning.
Sometimes MS breaks things just for fun... In Access 2003, only the maximum allowable SQL string length could cause problems as you built a recordset. Now, when using string data in a WHERE clause, the 'identifier' maximum is 128 characters. So, …
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

834 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