Returning Records with No Value (not null) if a specific field
-
How do I return records from a query where a specific field does not have a value. I have a query that will return records if the specific field has a value in it, but if the field does not have a value it does not return in record information. Please advise. Thanks in advance.
-
How do I return records from a query where a specific field does not have a value. I have a query that will return records if the specific field has a value in it, but if the field does not have a value it does not return in record information. Please advise. Thanks in advance.
dboy221 wrote:
How do I return records from a query where a specific field does not have a value.
SELECT * FROM MyTable WHERE SomeColumn IS NOT NULL
Upcoming events: * Glasgow: SQL Server 2005 - XML and XML Query Plans, Mock Objects, SQL Server Reporting Services... Never write for other people. Write for yourself, because you have a passion for it. -- Marc Clifton My website
-
dboy221 wrote:
How do I return records from a query where a specific field does not have a value.
SELECT * FROM MyTable WHERE SomeColumn IS NOT NULL
Upcoming events: * Glasgow: SQL Server 2005 - XML and XML Query Plans, Mock Objects, SQL Server Reporting Services... Never write for other people. Write for yourself, because you have a passion for it. -- Marc Clifton My website
Colin Angus Mackay wrote:
SELECT * FROM
I know this is an easy way to show the example but, being that it is an example, some poor schmo might actually use this in production. Might I suggest: SELECT SomeColumn1, SomeColumn2 FROM MyTable WHERE SomeColumn IS NOT NULL Never, never use select * in production.
topcoderjax - Remember, Google is your friend.
-
How do I return records from a query where a specific field does not have a value. I have a query that will return records if the specific field has a value in it, but if the field does not have a value it does not return in record information. Please advise. Thanks in advance.
-
Colin Angus Mackay wrote:
SELECT * FROM
I know this is an easy way to show the example but, being that it is an example, some poor schmo might actually use this in production. Might I suggest: SELECT SomeColumn1, SomeColumn2 FROM MyTable WHERE SomeColumn IS NOT NULL Never, never use select * in production.
topcoderjax - Remember, Google is your friend.
TopCoderJax wrote:
I know this is an easy way to show the example but, being that it is an example, some poor schmo might actually use this in production.
Since no columns where given as an example, there was no list from me to select from.
TopCoderJax wrote:
Might I suggest
You can suggest it. My my time is limited and I'm not going to spend time writing out a ficitious list only for the OP to come back and say it doesn't work because *I* supplied invalid column names - And that has happened on a number of occasions. Some people are increadibly thick or just don't want to understand what is going on. (NOTE: This is a general observation and may not apply to the current OP)
TopCoderJax wrote:
Never, never use select * in production.
I completely agree.
TopCoderJax wrote:
Remember, Google is your friend.
And one which most people shun for some bizzare reason. By the way, have you tried to set up a Custom Google Search[^]? It is great you can set filters on it so you get more relevant hits. I've set mine for code project, microsoft and my blog (because half the time I've done it before but I've forgotten how). I get most everything I want in the first couple of hits.
Upcoming events: * Glasgow: SQL Server 2005 - XML and XML Query Plans, Mock Objects, SQL Server Reporting Services... Never write for other people. Write for yourself, because you have a passion for it. -- Marc Clifton My website
-
TopCoderJax wrote:
I know this is an easy way to show the example but, being that it is an example, some poor schmo might actually use this in production.
Since no columns where given as an example, there was no list from me to select from.
TopCoderJax wrote:
Might I suggest
You can suggest it. My my time is limited and I'm not going to spend time writing out a ficitious list only for the OP to come back and say it doesn't work because *I* supplied invalid column names - And that has happened on a number of occasions. Some people are increadibly thick or just don't want to understand what is going on. (NOTE: This is a general observation and may not apply to the current OP)
TopCoderJax wrote:
Never, never use select * in production.
I completely agree.
TopCoderJax wrote:
Remember, Google is your friend.
And one which most people shun for some bizzare reason. By the way, have you tried to set up a Custom Google Search[^]? It is great you can set filters on it so you get more relevant hits. I've set mine for code project, microsoft and my blog (because half the time I've done it before but I've forgotten how). I get most everything I want in the first couple of hits.
Upcoming events: * Glasgow: SQL Server 2005 - XML and XML Query Plans, Mock Objects, SQL Server Reporting Services... Never write for other people. Write for yourself, because you have a passion for it. -- Marc Clifton My website
A well reasoned response, but I guess we'll have to remain in disagreement:) I've fixed too many programs/stored procedures where this caused problems; It is the equivilent of nails on a chalk board to me... it just makes my skin crawl. As to this:
Colin Angus Mackay wrote:
have you tried to set up a Custom Google Search[^]?
Really cool tip. I can't tell you how many times I wished they would add this feature. Truely appreciated. I'm going to try it out now. Thanks.
topcoderjax - Remember, Google is your friend.