Help Creating a Temp Table
-
All, I have been reading and trying diffrent ways to get this to work but the gist is I am trying to create a temp table that is slecting cloumns from multiple tables I cant see how a join would work and I have tried pass the columns from table2 as a varible..no luck The goal is to create one big table I can export off to a file I am using SQL 2008 Ent. Here is what I have: BEGIN If NOT Exists(Select * from tempdb..sysobjects Where id = object_id('tempdb.dbo.#temp')) SELECT firstname,lastname, INTO #TEMP FROM Table1 Select email, username into #temp from Table2 END
Regards, Hulicat
-
All, I have been reading and trying diffrent ways to get this to work but the gist is I am trying to create a temp table that is slecting cloumns from multiple tables I cant see how a join would work and I have tried pass the columns from table2 as a varible..no luck The goal is to create one big table I can export off to a file I am using SQL 2008 Ent. Here is what I have: BEGIN If NOT Exists(Select * from tempdb..sysobjects Where id = object_id('tempdb.dbo.#temp')) SELECT firstname,lastname, INTO #TEMP FROM Table1 Select email, username into #temp from Table2 END
Regards, Hulicat
Do you get any error message? Can you explain better your problem?
I Love T-SQL "Don't torture yourself,let the life to do it for you." If my post helps you kindly save my time by voting my post. www.aktualiteti.com
-
Do you get any error message? Can you explain better your problem?
I Love T-SQL "Don't torture yourself,let the life to do it for you." If my post helps you kindly save my time by voting my post. www.aktualiteti.com
-
All, I have been reading and trying diffrent ways to get this to work but the gist is I am trying to create a temp table that is slecting cloumns from multiple tables I cant see how a join would work and I have tried pass the columns from table2 as a varible..no luck The goal is to create one big table I can export off to a file I am using SQL 2008 Ent. Here is what I have: BEGIN If NOT Exists(Select * from tempdb..sysobjects Where id = object_id('tempdb.dbo.#temp')) SELECT firstname,lastname, INTO #TEMP FROM Table1 Select email, username into #temp from Table2 END
Regards, Hulicat
;with cte as(select t1.*, t2.* from table1 t1 cross join table2 t2) select * from cte OR ;with cte as(select t1.*, t2.* from table1 t1 ,table2 t2) select * from cte :)
Niladri Biswas