Hi Gaurav,
very helpfull query, thank you.
Can i suggest to add checks if the temporary tables already exists before creating them?
Something like:
IF OBJECT_ID('tempdb..#SearchResult') IS NOT NULL DROP TABLE #SearchResult
IF OBJECT_ID('tempdb..#SearchTestResult') IS...