create table #Source( SourceID int identity, SomeValue varchar(10))insert #Sourceselect 'Source 1' union allselect 'Source 2'select * into #Test from #Sourcewhere 1 = 2insert #Testselect 'Test'select * from #Testdrop table #Sourcedrop table #Test
SELECT SomeBasicIntColumn = ISNULL(CAST(SomeIdentityColumn AS INT),0), other columns INTO #SomeTempTable FROM dbo.SomeOtherTable WHERE 1 = 0;
SELECT *INTO dbo.newtableFROM dbo.oldtable_with_identityUNION ALLSELECT TOP (1) *FROM dbo.oldtable_with_identityWHERE 1 = 0
SELECT SomeBasicIntColumn = 0 + SomeIdentityColumn, other columns INTO #SomeTempTable FROM dbo.SomeOtherTable WHERE 1 = 0