- 判斷臨時表是否存在,存在則刪除
if OBJECT_ID('tempdb..#tempTable') IS NOT NULL begin DROP TABLE #temp_Table end
- 創建臨時表(' # '局部的臨時表僅在會話里邊, ' ## '全局的的臨時表)
create table #temp_Table( 字段1 約束條件, 字段2 約束條件, ...) create table #tempTable( 字段1 約束條件, 字段2 約束條件, ...)
- 刪除臨時表
DROP table #temp_Table
- 清空臨時表數據和約束
truncate table #temp_Table