1

Is there a way to Name a temp table with a variable date?

For Example:

DECLARE @SomeDate datetime = '12/31/2016'

Select * 
into #?? 
from Table

The end result I'm looking for is #201612

TJ8685
  • 11
  • 1

1 Answers1

1

In SQL Server and possibly others, temp tables (but not global temp tables) are only visible to the session. Multiple sessions can create the temp tables with the same name and they don't interfere with each other. So, possibly all you need is a fixed name.

Check this for more info: Scope of temporary tables in SQL Server

Community
  • 1
  • 1