November 22, 2006 at 1:00 pm
Hi all.
First, sorry for my bad english. I need some help on the following:
I have a stored procedure that query my Customer table and it has three parameters:
@customer varchar(500), @id_city int and @id_country int
all of them accepts null as incoming
Now, I want to get the registers from my Customer like this:
If I pass null to three parameters, all of my registers will be returned.
If I pass null to @id_city and some value to @customer and @id_country all registers that has @customer OR (not AND) @id_country will be returned.
If I pass null to @customer and some value to @id_city and @id_country all registers that has @id_city OR (not AND) @id_country will be returned.
And so on.
Example:
CUSTOMER TABLE:
#REGISTER | CUSTOMER | CITY | COUNTRY |
PELE | SANTOS | BRAZIL | |
2 | RONALDINHO | BARCELONA | SPAIN |
ROMARIO | RIO DE JANEIRO | BRAZIL | |
ADRIANO | MILAN | ITALY |
If I pass @customer = 'PELE' and Country = 'Spain' I want to be returned registers 1 and 2.
If I pass null to all three parameters, I want to be returned all four registers.
If I pass @city = 'santos' and @customer = 'ronaldinho' and @country = 'italy' registers 1,2 and 4 will be returned.
PS: I don't want dynamic SQL.
Please, help me.
Best regards,
Marco Alves.
November 22, 2006 at 1:08 pm
Please do not cross-post. We monitor all boards.
Finish the thread here pls : http://www.sqlservercentral.com/forums/shwmessage.aspx?forumid=9&messageid=325058
November 22, 2006 at 1:16 pm
how I can finish a thread?
November 22, 2006 at 1:19 pm
You can't. that's why I redirect the thread to a single point.
November 22, 2006 at 1:24 pm
ok. I get it.
But, a suggestion: Some boards here are correlated, like programming adn development.
I think that should exists an option to post some thread to more than one board. Not all, of course, a limit like two, three or four boards. All topics redirecting to some "central"/"default" topic.
Best regards,
Marco Alves.
November 22, 2006 at 1:30 pm
No need for that : all new posted get special attention, then active posts get special attention, then unanswered psot get recycled after 1 day. Not to mention that all question get posted in the daily newsletter .
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply