SQL Server 臨時表的刪除
來源:易賢網(wǎng) 閱讀:1401 次 日期:2014-12-16 13:32:36
溫馨提示:易賢網(wǎng)小編為您整理了“SQL Server 臨時表的刪除”,方便廣大網(wǎng)友查閱!

1、錯誤的刪除操作:

--錯誤的臨時表刪除操作,因為所在數(shù)據(jù)庫不同

IF EXISTS (SELECT * FROM sysobjects WHERE object_id = OBJECT_ID(N'[dbo].[#tempTable]') AND type in (N'U'))

Begin

DROP TABLE [dbo].[tempTable]

End

--錯誤的臨時表刪除操作,因為臨時表名已變

if exists (select * from tempdb.dbo.sysobjects where id = object_id(N'[#temptable]'))

Begin

drop table #temptable

End

2、正確的刪除方式:

--正確的臨時表刪除操作

if object_id('tempdb#tempTable') is not null Begin

drop table #tempTable

End

更多信息請查看IT技術專欄

更多信息請查看數(shù)據(jù)庫
易賢網(wǎng)手機網(wǎng)站地址:SQL Server 臨時表的刪除
關于我們 | 聯(lián)系我們 | 人才招聘 | 網(wǎng)站聲明 | 網(wǎng)站幫助 | 非正式的簡要咨詢 | 簡要咨詢須知 | 新媒體/短視頻平臺 | 手機站點

版權所有:易賢網(wǎng)