The procedure seems does not match with the tables and result table. I used the code provided and modified places where conflict with your current provided tables and it won't out put the result which makes it hard to understand the job your SP did about
the tables. Also, the result set is confusing and can't see the rule you get this result. With these problems and confusion, it's hard to provide a specific solution for yout.
However, you can try to use CTE with recursion in sql ot replace the cursors.
Member
140 Points
520 Posts
Query performance
Nov 28, 2019 10:50 AM|jsshivalik|LINK
Hi
I have below Stored Procedure to get the below desired result. Is there any best way without using Cursor
Thanks
Contributor
3140 Points
983 Posts
Re: Query performance
Nov 29, 2019 09:00 AM|Yang Shen|LINK
Hi jsshivalik,
The procedure seems does not match with the tables and result table. I used the code provided and modified places where conflict with your current provided tables and it won't out put the result which makes it hard to understand the job your SP did about the tables. Also, the result set is confusing and can't see the rule you get this result. With these problems and confusion, it's hard to provide a specific solution for yout.
However, you can try to use CTE with recursion in sql ot replace the cursors.
You can refer to SQL Server Recursive CTE see if you can get rid of the cursors by CTE.
Best Regard,
Yang Shen