i am using below query to generate some information of around 7k lines. but the issue is that the query is taking too much time to complete just 7k line. i need to fine tune it.
I use the SQL Profiler to auto create the indexes needed for a fine tune query.
Enter in SSMS (SQL Server Management Studio) -> Tools -> SQL Server Profiler.
Click Connect, and then click Run, to start a new trace.
Execute your slow query now, so the profiler can capture and record it.
Stop the query and File -> Save it.
In the menu, click Tools -> Database Engine Tuning advisor.
Click Connect when it opens, and in Workload, select file, and click the first button on the right (binoculars one). Then select the file you have just saved.
Select now the checkbox of your database, and click the "Start Analysis" button (below the "View" and "Action" menu).
Once it finish, open "Action" menu, and click in "Apply Recommendations".
Now you should have a fast and fine tuned query.