Good day,
I have an SSRS report executing an SP that executes multiple SP
I had a while loop with temp tables which i changed to param tables and buidling dynamic "union" query
Please any ideas on optimizing the below much faster, it ranges for a month so i end up having 31 * 2 dynamic t-sql exec SP for @SQLTest & @SQLTestUnits > both executes the same SP with different param and resultsets stored separately
I cant touch the main sp "usp_Client_Base" > looking for ways to improve performance from my current sp
I read the while are bad hence why im using it to build the dynamic qry
Create SP Test:
SET @TempDate = @DateFrom
SET @Ccnt = 0
SET @CNT = DATEDIFF(D,@DateFrom,@DateTo)
SET @SQLTest = ''
SET @SQLTestUnits = ''
SET @CcntTest = 0
WHILE @CcntTest < (@Cnt +1)
BEGIN
SET **@SQLTest** = @SQLTest + ' EXEC [dbo].[usp_Client_Base] ''' + CONVERT(VARCHAR(200),@PoolXML) +''',Null,''' + CONVERT(VARCHAR(11), @Date, 106) +''', Null, '''', Null, Null, Null,0, 1, 0,0,0,Null,0,0'
SET **@SQLTestUnits** = @SQLTestUnits + ' EXEC [dbo].[usp_Client_Base] ''<objectlist><object type="CodeLookup" code="HOLD" parentChild="0" grouping="0"/></objectlist>'',Null,''' + CONVERT(VARCHAR(11), @Date, 106) +''', Null,'''',Null, Null, Null,0,1,0,0,0,Null,0,0'
SET @CcntTest = @CcntTest + 1
SET @TempDate = DATEADD (D , @CcntTest, @DateFrom )
END
--INSERT INTO @Client_Test
EXEC sp_executesql @SQLTest
--INSERT INTO @Client_TestUnits
EXEC sp_executesql @SQLTestUnits
Possible to simultaneously/parallel from within the script to "sp_executesql @SQLTest & @SQLTestUnits" without locking one another?
Please any ideas on other methods, Thank you!