I have a closed source ASP.NET system that is calling a very expensive SQL view:
SELECT TOP 100 PERCENT *
FROM [v]
WHERE [u] = 9999
ORDER BY [ID]
I have access to the database, so I can change the view - there is no easy way to make the view faster.
I would like to programmatically change the behaviour of the view based on which IIS server is performing the request.
Is this possible?
E.g. I would like to create a stored procedure that would be called from the view, and this stored procedure would return a table that mimics the current view, but if called from a particular IIS server would return something different.
Is it possible to modify the view to call a stored procedure so that the asp.net code doesn't need any modifications?
I can see from other stack overflow articles how to call a stored procedure from a view, but how can I access the where clause inside the stored procedure?