SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
Register Now and get your question answered!
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 SQL 2012, remove column if null in all rows
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Yak Posting Veteran

56 Posts

Posted - 11/11/2012 :  13:20:38  Show Profile  Reply with Quote

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

In (Som, Ni, Yak)

17684 Posts

Posted - 11/11/2012 :  20:01:49  Show Profile  Reply with Quote
Dynamic SQL is the only way

Time is always against us

Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.05 seconds. Powered By: Snitz Forums 2000