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
 Is it possible to restrict columns from select

Author  Topic 

jim_jim
Constraint Violating Yak Guru

306 Posts

Posted - 2013-03-06 : 14:21:51
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
Master Smack Fu Yak Hacker

3873 Posts

Posted - 2013-03-06 : 14:37:08
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

306 Posts

Posted - 2013-03-06 : 15:01:23
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
Master Smack Fu Yak Hacker

4614 Posts

Posted - 2013-03-06 : 16:28:03
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
   

- Advertisement -