View a temporary table created from a stored procedure

I have a stored procedure in SQL 2005. The stored procedure actually creates temporary tables at the beginning of the SP and deletes them at the end. Now I am debugging SP in VS 2005. Between SP I would like to know the contents in a temporary table. Can anyone help while viewing the contents of the temporary table at runtime.

Thanks Vinod T

+5
source share
6 answers

There are several types of temporary tables, I think you could use a table that is not discarded after the SP used it. Just make sure you don't call the same SP twice, or you get an error message trying to create an existing table. Or just release the temporary table after you see its contents. So instead of using a table variable ( @table) just use #tableor##table


From http://arplis.com/temporary-tables-in-microsoft-sql-server/ :

Local temporary tables

  • The prefix of local temporary tables with a single number sign (#) as the first character of their names, for example (#table_name).
  • , . , Microsoft SQL Server.

  • (##) , (## table_name).
  • , .
  • , , , Microsoft SQL Server.
+14

, * (, ) .?

. , .

+7

, temp, .

sp_select github.

, exec sp_select 'tempdb..#temp' , .

+5

: Visual Studio Microsoft , SQL.

, #temp, ## temp , , .

: ... , Microsoft ... SQL .

, , SQL, , #temp.

+2

.

SELECT * FROM #Name

USE [TEMPDB]
GO

SELECT * FROM syscolumns 
   WHERE id = ( SELECT id FROM sysobjects WHERE [Name] LIKE '#Name%')

+1

, , :

-- Get rid of the table if it already exists
if object_id('TempData') is not null
  drop table TempData

select * into TempData from #TempTable
+1

All Articles