sql server - Temp table with ### (triple) or more hashes -


we know in sql server, creating table # means "local temp table" , ## means "global temp table".

but when create table below:

create table ###mytable(intcolumn int, valuecolumn varchar(100)) 

is table local or global temp table? how can test it? when tried select via:

select * #mytable -- sql said doesn't exists select * ##mytable -- sql said doesn't exists select * ###mytable -- output 

if third case true, doesn't mean general table name ###mytable? , wouldn't see table in ssms table explorer every other physical table?

what happen if start adding multiple # (hashes) before table name?

it global temp table. considering third # part of tablename. if check temdb database can see table without session id. if temp table created local temp table can see particular sessionid appended temptable name, since there no session id appended temp tablename global temp table.

create table ###mytable   (      intcolumn   int,      valuecolumn varchar(100)   )  

after running above query

goto server -> databases -> system database -> tempdb -> temporary tables

you can find created global temptable below image.

enter image description here


Comments

Popular posts from this blog

c++ - QTextObjectInterface with Qml TextEdit (QQuickTextEdit) -

javascript - angular ng-required radio button not toggling required off in firefox 33, OK in chrome -

xcode - Swift Playground - Files are not readable -