SQL Server Central is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
Search:  
 
 

Flexible searching on tables

By kornolio, 2003/12/03

Total article views: 154 | Views in the last 30 days: 4

In my company's web site there are search pages for allowing users to search info on one or more tables (or in my case a select with 10 joins). Often the requirements for these search pages change over time with users either requesting additional columns to search or remove columns that are no longer useful.

The search page that the script is based on looks like this...

Date received |______|
Area |_______|
Source of budget |______|

[Submit]

I came up with the following stored proc to grab results from the source table w/c still allows me flexibility when it came to adding or removing searchable columns.

The script will work but it heavily depends on having an identity key on the source table and it is necessary to be mindful of the no. of columns used in the table variable so as not to downgrade performance.

At first the delete statements will seem hard to understand then when you get the hang of it you'll appreciate the flexibility the script offers and then you're gonna send me $10,000 on my birthday.

By kornolio, 2003/12/03

Total article views: 154 | Views in the last 30 days: 4
Your response
 
 
Related tags

Miscellaneous    
 
Already registered?  

Free registration required

To read the rest of this article, and access thousands of other articles, we ask you to register on the site and subscribe to our newsletters.

Register

E-mail address:
Password:
Password (confirm):

  

Subscriptions

We ask you to register on the site and subscribe to our newsletters. Subscribing to our newsletters gets you:

  • ALL of our content (thousands of articles, scripts, and forum postings)
  • A daily newsletter (example)
  • A weekly news round up (example)
  • The opportunity to ask and answer questions in our forums
  • A daily Question of the Day to test and help you increase your knowledge of SQL Server.

We ask that you give the newsletter a try for a week. Over 200,000 SQL Server Professionals a day find it entertaining and useful. If not, you are welcome to unsubscribe at anytime.

Steve Jones
Editor, SQLServerCentral.com