Solved

Help with sp_executeSQL calling a stored procedure with multiple parameters

Posted on 2014-01-23
4
486 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:
ScottPletcher 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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

How to leverage one TLS certificate to encrypt Microsoft SQL traffic and Remote Desktop Services, versus creating multiple tickets for the same server.
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.
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
This video discusses moving either the default database or any database to a new volume.

708 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now