Troubleshooting an inefficient proc which includes several parameters including the final parameter being an entire large SELECT statement string with numerous joins. Takes 30 minutes.
Is there a better method to obtain the values retrieved in the SELECT and the pass as parameter. Could consider VIEW or FUNCTION however I'm told the SELECT string is subject to change, perhaps every time it's issue from CRM (Dynamics)
Declare @ResultCode int
Declare @Results varchar(max)
exec @ResultCode = dbo.someproc 2, null, null, null, N'SELECT <massive 2000 row select statement''>
Thanks in advance for any advice