Paul Scotchford <paul.scotchford-eds@eds.com> wrote in message news:<40a2eaeb$0$200$75868355@news.frii.net>...[color=blue]
> Hi all, Thanks in advance to any contributions to my question.
>
> Im running SQLServer 2000 in a Win 2000 Server env.
>
> Background:
> ==========
>
> The database has many views that range from simple to complex joins on
> tables.
>
> The selection criteria is fixed eg. 'Where TaskTypeIdent = 2204 and
> OutcomeId = 123 or 2322 or 1222 and
> CicType = 87878 ... etc etc
>
> Requirement:
> ===========
>
> Now what I would like to do is be able to change the 'where =' value
> part ie. 2204, dynamically if and when required, and it will be
> required.
>
> In other words there won't be a DBA handy to do this when it changes
> hence I would like to write a front end UI to allow the user to easily
> manage this.
>
> There are upwards of 200 views like this.
>
> Question:
> ========
>
> Where in the system metadata can I access (if possible) the source of
> the View such that I can update it with the new values. eg. 'Where
> TaskTypeIdent = 7627 and OutcomeId = 2322 or 94847 or 989 and CicType =
> 1111 ... etc etc
>
> Many thanks
>
> Paul
>
>
> *** Sent via Developersdex
http://www.developersdex.com ***
> Don't just participate in USENET...get rewarded for it![/color]
You can use ALTER VIEW to change a view's definition, but you should
probably consider a different approach. In general, you don't want
users creating or modifying any objects in your database, because
allowing them to do so would create significant security and
maintenance issues.
It's not clear from your description why you hard-code values at all -
why not simply pass the values to your query at runtime, perhaps as
stored procedure parameters? And/or replace views with table-valued
functions, which accept parameters for the search values?
If your fundamental requirement is for reporting, you may want to look
at using a reporting package which will build queries for your users
directly (MS Reporting Services, Crystal Reports etc.). Or for a
stored procedure solution, check out this article:
http://www.sommarskog.se/dyn-search.html
Simon