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 |
|
jasonfisher
Starting Member
7 Posts |
Posted - 2005-02-08 : 06:33:23
|
| Hi:I'm trying to create an ad-hoc query on a Asp.net page for user. Besides the usual Boolean operators, Field Names, Comparison operators & Field Values, the ad-hoc query also involves multiple tables, eg [Customers] , [Members] & [Orders].Now I have difficulties on writing a TSQL sp on how to take the dynamic query with different tables under consideration. User might simply query each individual tables (eg, Customers with age > 25) or combination of tables (eg, Membered Customers with Orders Amt > 1000 between 1/1/2005 - 1/31/2005)I have look up a lot dynamic query on the net but all are with only 1 single table to hit. Could anyone give me a direction on how to write a dynamic query script with multiple tables under consideration? Much appreciated.ps: The ad-hoc query only contains these defined tables, no other table will be involved. |
|
|
spirit1
Cybernetic Yak Master
11752 Posts |
Posted - 2005-02-08 : 07:14:01
|
well you could build your string dynamicaly with paramtere use in the where and execute it via sp_executeSql.look it up in BOL = Books Online = Sql Server Help.Go with the flow & have fun! Else fight the flow |
 |
|
|
|
|
|