I want to have a Table Variable, in which I want to have structure of a physical table.
How to declare a table variable with existing structure?
Eg: Declare @tblTemp table()
<-- Here I stuck with how to give structure of an existing physical table? SELECT * INTO @tblTemp FROM tbl_PhysicalTable where 1=2
<-- This wont work for table variable, but works for Temporary Table.
And finally I want to do a insert into the Table variable like, with conditions and UNIONS.
INSERT @tblTemp (*)
(SELECT * FROM tbl_PhysicalTable WHERE nID= 1125
SELECT * FROM tbl_PhysicalTable1 WHERE nID= 1125)
Then Finally, I will have @tblTemp of filtered results.
How to achieve this?
Thanks in Advance.