Skip to content

Instantly share code, notes, and snippets.

Created December 7, 2012 07:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/57f415f6e7721bddfebd to your computer and use it in GitHub Desktop.
Save anonymous/57f415f6e7721bddfebd to your computer and use it in GitHub Desktop.
Local Temporary Table
--本機暫存資料表名稱的前置詞 (#table_name)
--儲存於系統資料庫tempdb的sysobjects資料表(Disk/IO)
--只在目前工作階段中才可以看見
--目前工作階段結束時,會自動卸除所有其他本機暫存資料表
IF OBJECT_ID('tempdb..#tbl_TMP') IS NOT NULL
BEGIN
DROP TABLE #tbl_TMP
END
CREATE TABLE #tbl_TMP(
EmpID varchar(20),
Name varchar(100)
)
INSERT INTO #tbl_TMP
SELECT TOP 10 EmployeeID ,FirstName
FROM [Northwind].[dbo].[Employees]
SELECT * FROM #tbl_TMP
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment