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

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Is it possible to restrict columns from select
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

jim_jim
Constraint Violating Yak Guru

USA
302 Posts

Posted - 03/06/2013 :  14:21:51  Show Profile  Reply with Quote
Hi All
Is it possible to restrict the feilds returned from a select statement which means i want to see only the feilds in a record which has some data in them and want to ignore the other feilds where feild is null and i dont know in advance which feilds are null and that is the reason i cannot have it in the where condition

so for example
Select * from table_name where column1 =''xxx' returns 1 record with 15 feilds which is the number of feilds existing in the table.

if for example there are 3 feilds where the data in those feilds is null i do not want them to be returned in my select query

Thanks

James K
Flowing Fount of Yak Knowledge

3661 Posts

Posted - 03/06/2013 :  14:37:08  Show Profile  Reply with Quote
I assume you mean that if the data in every row for a given column is null, then you don't want that row to be included in the result set. To do that, you would have to write a dynamic query.

If you describe the reason for wanting it that way, may be people would be able to suggest alternatives. To me at least, the unpredictability of the columns returned based on the variations in data makes it hard to process the result set. So I am not able to imagine what your reason for wanting that might be.
Go to Top of Page

jim_jim
Constraint Violating Yak Guru

USA
302 Posts

Posted - 03/06/2013 :  15:01:23  Show Profile  Reply with Quote
Iam trying to compare two requests(records) one request from previous year(2012) and 1 request from current year(2013) and want o capture only the feilds from the two records where there is a change in data and ignore/hide all the other feilds where data has remained the same

Hope the above is making sense
Go to Top of Page

Lamprey
Flowing Fount of Yak Knowledge

4614 Posts

Posted - 03/06/2013 :  16:28:03  Show Profile  Reply with Quote
The shoet answe is NO, you cannot. I answered your question in the other thread you started on this topic
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=183488
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.03 seconds. Powered By: Snitz Forums 2000