Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
xdk1x
Starting Member
9 Posts |
Posted - 2004-06-07 : 08:36:34
|
| Hi!I want to JOIN a table with a temporary created table within a procedure. The table is declared as followed:DECLARE @tmpPooldat TABLE (P1 CHAR(6), P2 CHAR(6), P3 CHAR(6), P4 CHAR(6), P5 CHAR(6), P6 CHAR(6))The JOIN Statement:SELECT ...FROM tbSchaeden JOIN @tmpPooldatON tbSchaeden.ZugJahrMonat = @tmpPooldat.P1;The error message:Server: Nachr.-Nr. 137, Schweregrad 15, Status 2, Zeile 46Must declare the variable '@tmpPooldat'.Can't I join with a temporary table?Thanks for your help!Daniel |
|
|
derrickleggett
Pointy Haired Yak DBA
4184 Posts |
Posted - 2004-06-07 : 08:42:17
|
| Is your select inside of dynamic SQL? If it is, then it won't work. Also, your statement won't work, but this will:SELECT *FROM tbSchaeden ts JOIN @tmpPooldat tpON ts.ZugJahrMonat = tp.P1MeanOldDBAderrickleggett@hotmail.comWhen life gives you a lemon, fire the DBA. |
 |
|
|
mr_mist
Grunnio
1870 Posts |
Posted - 2004-06-07 : 08:43:06
|
| Alias the temporary table and it should work fine.-------Moo. :) |
 |
|
|
xdk1x
Starting Member
9 Posts |
Posted - 2004-06-07 : 08:48:48
|
| Thanx guys!!! Now it works... |
 |
|
|
|
|
|