Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Select not null columns from a table

SoofiDec 24 2020

Hi All,
I need to generate a report which displays the columns which has data.
Here is my example,

image.png
So my sample table has num1 ... num3 and col1.. col3. And you can see there is completely no data for the columns Num2 and Col2 which I need to exclude while generating the report.
My final output should be like this

image.pngNOTE - The above case is just a sample, actual data and number of columns will vary.
What will be best way to achieve this.
I am using Oracle Database 12c (12.2.0.1.0 )
Thanks in advance,
Soofi

Comments

gdarling - oracle
I don't claim to be a SQLServer guru, or well, even moderately intelligent at it, but you might want to try using OpenQuery instead of linked server directly.

select * from openquery(MYLINKNAME,'select * from table where pk=1)

Hope it helps, corrections/comments welcome.
Greg
1 - 1

Post Details

Added on Dec 24 2020
7 comments
7,300 views