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 |
|
Brittney10
Posting Yak Master
154 Posts |
Posted - 2011-02-09 : 18:34:10
|
I created a table variable and want to join that table with another "actual" SQL table. However, when i try to select columns from both the table variable and the actual table, the table variable columns don't show up. It appears that my join between the two tables worked and when i select * from my @variable_table everything pulls correctly...Here's an example of what i'm trying to do:SELECT TableA.ColumnX, TableA.ColumnY, TableA.ColumnZ, var.ColumnA, var.ColumnB, var.ColumnCFROM TableA LEFT JOIN @variable_table var ON TableA.ColumnX = var.ColumnA I'm just not sure why the variable columns aren't pulling any data. Any help or pointers would be much appreciated! |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
|
Coolganny
Starting Member
3 Posts |
Posted - 2011-02-10 : 00:36:50
|
| Your query seems to be correct. Can you show some sample data?Ganesh Ravi |
 |
|
|
Ranjit.ileni
Posting Yak Master
183 Posts |
Posted - 2011-02-10 : 01:06:21
|
Hi,quote:
SELECT TableA.ColumnX, TableA.ColumnY, TableA.ColumnZ, var.ColumnA, var.ColumnB, var.ColumnCFROM TableA LEFT JOIN @variable_table var ON TableA.ColumnX = var.ColumnA I'm just not sure why the variable columns aren't pulling any data. Any help or pointers would be much appreciated!
your query seems to be correct....may be reason for quote: variable columns aren't pulling any data
there may be no data which supports ON filter condition--Ranjit |
 |
|
|
MIK_2008
Master Smack Fu Yak Hacker
1054 Posts |
Posted - 2011-02-10 : 01:27:07
|
quote: Originally posted by Brittney10SELECT TableA.ColumnX, TableA.ColumnY, TableA.ColumnZ,var.ColumnA, var.ColumnB, var.ColumnCFROM TableA LEFT JOIN @variable_table var ON TableA.ColumnX = var.ColumnA I'm just not sure why the variable columns aren't pulling any data. Any help or pointers would be much appreciated!
Seems that the Join Condition is failing (Make sure both columns have same datatypes and data) |
 |
|
|
Brittney10
Posting Yak Master
154 Posts |
Posted - 2011-02-10 : 15:20:40
|
| It appears it was after all and issue with my join. |
 |
|
|
|
|
|
|
|