tsql - SQL Server - replace view with stored procedure -


i have closed source asp.net system calling expensive sql view:

select top 100 percent *  [v]   [u] =  9999  order [id] 

i have access database, can change view - there no easy way make view faster.

i programmatically change behaviour of view based on iis server performing request.

is possible?

e.g. create stored procedure called view, , stored procedure return table mimics current view, if called particular iis server return different.

is possible modify view call stored procedure asp.net code doesn't need modifications?

i can see other stack overflow articles how call stored procedure view, how can access clause inside stored procedure?

given asp.net code presumably has select * [view] code embedded in , cannot change that, have following hurdles:

  1. you need create multi-statement table-valued function can detect iis instance you're querying without tailored inputs application (e.g., @ user or service account, ip address). benefit of using multi-statement table-valued view can create 2 separate select statements , conditionally return 1 or other. can in stored procedure well, think you'll find simpler call multi-statement table-valued function view stored procedure.

  2. you need change view select * new multi-statement table-valued function.

caveats

when change definition of view utilized application, changing view other user or application accesses it. here discussion on how see has been using particular view , how often. recommend looking whether or not have other applications or reporting tools pulling view, changing underlying code potentially break other applications.


Comments

Popular posts from this blog

javascript - Thinglink image not visible until browser resize -

firebird - Error "invalid transaction handle (expecting explicit transaction start)" executing script from Delphi -

mongodb - How to keep track of users making Stripe Payments -