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.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 SQL 2012, remove column if null in all rows

Author  Topic 

BigMeat
Yak Posting Veteran

56 Posts

Posted - 2012-11-11 : 13:20:38
Hi

I have a SQL 2012 DB and have a select statement that returns 30 rows of info. eg row contains years values from year 2000 to 2020. In some cases the we may not have data form year 2000 so I want my TSQL to only return columns that have values, eg do not return year 2000 all values are null

I came across this method http://stackoverflow.com/questions/11227288/remove-null-columns-from-pivot-tsql

But i wanted to see if there was another way of doing this

many thanks in advance

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2012-11-11 : 20:01:49
Dynamic SQL is the only way


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page
   

- Advertisement -