What is the difference between a Local temporary table and a Global temporary table? How is each one used?

Q

What is the difference between a Local temporary table and a Global temporary table? How is each one used?

✍: Guest

A

Answer1:
Local templrary table will have a single # (#tablename) appended with the table name.Global templrary table will have Double # (##tablename) appended with the table name.
Ex:create table #table1
local temp. table will be available until the session who created it logs out, but global temp. table is available till the last session gets close in SQLServer.

Answer1:
Local temporary tables are visible only in the current session; global temporary tables are visible to all sessions.Prefix local temporary table names with single number sign (#table_name), and prefix global temporary table names with a double number sign (##table_name).

2014-10-15, 1531👍, 0💬