I wonder if it is possible to connect multiple files or query windows in SSMS to one session? The reason is that I want to use local temporary tables that are created in one file/query-window in other file/query-windows. As local temporary tables have session scope this seems to be the only way to achieve this.

We use the temp tables for separating session data in our application. I use SSMS for development and in the development context it would be useful to have the same tmp tables available in multiple SSMS windows.

What i do now is copy the creation code of the tmp tables in all query windows, then evaluate that part and then cut them out again. So they are avaible in that session, but that's a bit cumbersome. So basically it is an SSMS question and not a SQL Server question.

  • How about using all the queries in stored procedure. This wont be possible if they use multiple databases but this can be done if all queries refernce to one DB and then you can use Local Temp table as well
    – Shanky
    Aug 19, 2015 at 11:03
  • @Shanky The term query is a bit confusing here. I don't mean database queries (like select, update etc.). SSMS calls edit windows queries too, and that's what i refer to.
    – Gertjan
    Aug 19, 2015 at 11:59

1 Answer 1


It is not possible to share a local temporary table between connections.

Local temporary tables are scoped to a single session, but global temporary tables are visible to any user and any connection after they are created, and are deleted when all users that are referencing the table disconnect from the instance of SQL Server.

Global temporary tables have two number signs (##) as the first characters of their names, for example:

    c1 integer NULL

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.