>
>Table variable is just a local variable declared as table (WOW! what an explanation :-))
>Table variable is kept in memory, temp tables are created in TempDB.
>To declare table variable:
>
>DECLARE @MyTable TABLE (Fld1 Int, Fld2 varchar(50) etc...)
>
>
>Then you could use them as normal table with one condition everywhere you use them in JOIN you must give them alias, something like:
>
>SELECT MyTempTable.*
> FROM @MyTable MyTempTable
> LEFT JOIN OtherTable ON ON MyTempTable.PK = OtherTable.Fk
>
>SELECT OtherTable.*
> FROM OtherTable
> LEFT JOIN @MyTable MyTempTable ON OtherTable.Pk = MyTempTable.FK
>
>
Thank you very much, Borislav. I guess a table variable is faster to execute than a local temporary table.
"The creative process is nothing but a series of crises." Isaac Bashevis Singer
"My experience is that as soon as people are old enough to know better, they don't know anything at all." Oscar Wilde
"If a nation values anything more than freedom, it will lose its freedom; and the irony of it is that if it is comfort or money that it values more, it will lose that too." W.Somerset Maugham