Clearing temp tables

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Esteban404
    New Member
    • Nov 2007
    • 4

    Clearing temp tables

    //using C# 2005, MS SQL 2000(prod) and SQL Express 2005 (dev)

    My sprocs all have a clearing mechanism at the end like this for each temporary table I use:
    --drop temporary tables
    IF EXISTS(SELECT name FROM [DBNAME]..sysobjects WHERE name = N'#Temp' AND xtype='U')
    DROP TABLE #Temp

    Every once in a while, something will happen to cause a hiccup and the table doesn't clear. The result is no results, not an error message (reader fails). I added the same code to the beginning of the procedure and it helped, but I didn't think that a temp table would persist in sysobjects. This happens from within using blocks in C# and I'm "sure" the connection is closed in code anyway.

    Is this a known issue? I didn't really find anything similar in the msdn2 or sql areas.

    TIA

    _E
    Last edited by Esteban404; Dec 26 '07, 07:09 PM. Reason: the reader actually fails to return anything because the temp table is still there!
  • Esteban404
    New Member
    • Nov 2007
    • 4

    #2
    This turned out to be a symptom of a mis-configured server with a linked server. The RPC settings were not turned on, so were not cleared in a timely fashion if the connection was severed/halted.

    Comment

    Working...