English 中文(简体)
why Temporary tables not remove after completed their scope? [duplicate]
原标题:
This question already has answers here:
Closed 12 years ago.

Possible Duplicate:
Why are temporary tables not removed from tempdb in SQL Server?

We have created Temporary tables in a stored procedure and while running the stored procedure the Temparory table is created in the TempDB.

In my SP I have written code to drop that temporary table after completion of all operations manually.

But it is still there in the TempDB and not dropped. But when I restarted the SQL connection then the table had been dropped. I don t understand how this type of scenario happen in my DB.

Why are my temporary tables not dropped after completion of their scope?

Can anyone help me out this problem?

最佳回答

I m not sure why your table is not being dropped, but could you get away with using a table variable (@TableName) instead of a temp table (#TableName)? Then you wouldn t have to worry about dropping it at all, and it would be removed as soon as it goes out of scope...

问题回答

暂无回答




相关问题
Export tables from SQL Server to be imported to Oracle 10g

I m trying to export some tables from SQL Server 2005 and then create those tables and populate them in Oracle. I have about 10 tables, varying from 4 columns up to 25. I m not using any constraints/...

SQL server: Can NT accounts be mapped to SQL server accounts

In our database we have an SQL server account that has the correct roles to access some of the databases. We are now switching to windows authentication and I was wondering if we can create a NT user ...

SQL Server 2000, ADO 2.8, VB6

How to determine if a Transaction is active i.e. before issuing Begin Transaction I want to ensure that no previous transaction are open.. the platform is VB6, MS-SQL Server 2000 and ADO 2.8

热门标签