| Author |
Topic |
|
aakcse
Aged Yak Warrior
570 Posts |
Posted - 2012-08-08 : 10:46:30
|
I have 2 tables, I need to display data as below, with our joining these tableTab1 ( col1,col2) Tab2(Col5,Col6) I want to display data in the result, where ever I have data for Tab1's Col1,col2 the corresponding Tab2 col5 & Col6 will have empty '' value vice versaCol1 Col5 Col6 Col2A Null Null BNull X Y Null -Neil |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2012-08-08 : 10:49:12
|
| how are tables related? are there some common columns? if not, it doesnt make sense to show values side by side------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
aakcse
Aged Yak Warrior
570 Posts |
Posted - 2012-08-08 : 11:09:59
|
| The tables are not related, say if table 1 has 5rec and table 2 has 7rec.It should display 5+7 records =12 records in any ordersuch that if I am displaying tab1 data only tab1's columns should have value tab2 columns should be blank.-Neil |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2012-08-08 : 11:18:54
|
i dont know why you need to do that but anyways here you goSELECT Col1,CAST(null as <datatype of col5>) AS Col5,CAST(null as <datatype of col6>) AS Col6,Col2FROM Tab1UNION ALLSELECT Null,Col5,Col6,NullFROM Tab2 ------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
aakcse
Aged Yak Warrior
570 Posts |
Posted - 2012-08-08 : 14:12:38
|
| this works perfectly Visakh... you rock man... I have seen most of your and few others reply in this forum, if you dont mind sir.. do you own this site?Thanks-Neil |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2012-08-08 : 14:17:58
|
quote: Originally posted by aakcse this works perfectly Visakh... you rock man... I have seen most of your and few others reply in this forum, if you dont mind sir.. do you own this site?Thanks-Neil
nope...i'm just a fellow poster here ------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
robvolk
Most Valuable Yak
15732 Posts |
Posted - 2012-08-08 : 14:19:06
|
Visakh doesn't technically "own" the site, that would be Bill Graziano (graz). He just "owns" the lead in answers. |
 |
|
|
aakcse
Aged Yak Warrior
570 Posts |
Posted - 2012-08-08 : 14:49:45
|
| Well hats off to all, you guys are doing a great great(Can't call it as job as you are not getting paid :) :) ) help to people like us :) & Many thanks to Bill Graziano. believe me even msdn does not get this many hits for SQL Server and we need to wait for a day sometimes to get answer from msdn forum. Bill G (Gates) will soon get in touch with Bill G :)My apology for taking little offline-Neil |
 |
|
|
|