Please start any new threads on our new site at We've got lots of great SQL Server experts to answer whatever question you can come up with.

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
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
 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

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

many thanks in advance

In (Som, Ni, Yak)

17689 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  
 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.03 seconds. Powered By: Snitz Forums 2000