Solved

Help with sp_executeSQL calling a stored procedure with multiple parameters

Posted on 2014-01-23
4
499 Views
Last Modified: 2014-01-27
Hi experts,

The attached code loops through a temporary table and runs a complex validation procedure on each row.

I am looking at ways this could be speeded up and am investigating sp_executeSQL as opposed to Exec.  I cannot get it to work...the called procedure is still expecting the original parameter names...see the commented line above the sp_executeSQL  call.

I have been really struggling with this, and have looked at BOL.  If anyone can help me untangle it I'd appreciate it.

Colsp-executeSQL.docx
0
Comment
Question by:colinspurs
  • 3
4 Comments
 
LVL 69

Accepted Solution

by:
Scott Pletcher earned 500 total points
ID: 39803819
Changing to sp_executesql won't speed it up.

Ways to improve performance:
1) Make ID a primary key on @ProjectTables (i.e., cluster @ProjectTables by ID).
2) Add an index to TEMP_SITES_AND_TABLES on TABLE_NAME that includes project and site_id (not needed if T_S_A_T is clustered on table_name).
0
 
LVL 3

Author Comment

by:colinspurs
ID: 39806300
Thanks Scott.

T_S_A_T is actually a table variable in the original code.

I have updated the script (attached) but there is no discernible difference in performance.

The execution plan suggests a bunch of missing indexes so I'll try those too.

ValidateProc.docx
0
 
LVL 3

Author Comment

by:colinspurs
ID: 39812304
Indexes made no great difference...think I'll park this one on the fact that sp_executeSQL would not help.
0
 
LVL 3

Author Closing Comment

by:colinspurs
ID: 39812305
Thanks.
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

There have been several questions about Large Transaction Log Files in SQL Server 2008, and how to get rid of them when disk space has become critical. This article will explain how to disable full recovery and implement simple recovery that carries…
This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

820 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question