Tuesday, February 21, 2012

Returning different table results based upon variable

I hope this is simple and I'm just not seeing the answer.

Problem: I have two tables one with Shipping Address and one with Home Address. I want to return the Home Address unless it's empty and then I want to return the Shipping Address. The query is going to be by the stae field to narrow down results, so state=CA. If the Home Address state in not empty and state is 'CA' return address, if it is empty the return shipping address if state is 'CA'.

This is for MS SQL 2000 for planned stored procedure to display results on a webpage; Latest Service Pack also.

If I didn't need to check the null status and failover I have it working for me now. But not all records are filled out correctly and I don't want to auto-populate them.

Thank you.Okay I think I figured it out with a union statement and two selects...

No comments:

Post a Comment