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.
Author |
Topic |
akpaga
Constraint Violating Yak Guru
331 Posts |
Posted - 2013-08-12 : 11:48:43
|
Hi friendsI have following query populating a report on front endselect * from Customers.customer_name cnjoin Houston.Customer_address caon cn.id=cd.IDThe front end report now should have a city parameter and whenever the city is chosenthe query should change like this say -the city chosen is Dallasselect * from Customers.customer_name cnjoin Dallas.Customer_address caon cn.id=cd.IDi.e the database now has been changed to Dallas.Customer_Address..Can this be done using case statements? Please explain..Thank You |
|
James K
Master Smack Fu Yak Hacker
3873 Posts |
Posted - 2013-08-12 : 11:59:48
|
It probably is possible, but not easy, clean, or recommended. The reason for that is that the database design is not sound. Naming tables based on data can lead to all kinds of problems. Ideally you should create a single table for customers with multiple columns, one for a customer_id, others for firstname, lastname, address, city, zip code etc. You can further normalize it if you wish by having a Cities table and referring to that table in the city column of the customers table. |
|
|
denis_the_thief
Aged Yak Warrior
596 Posts |
Posted - 2013-08-12 : 12:11:56
|
Your design does look worrysome.But to answer your question, you could acheive this with Dynamic SQL. |
|
|
|
|
|