Solved

Help with sp_executeSQL calling a stored procedure with multiple parameters

Posted on 2014-01-23
4
510 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

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

Audit has been really one of the more interesting, most useful, yet difficult to maintain topics in the history of SQL Server. In earlier versions of SQL people had very few options for auditing in SQL Server. It typically meant using SQL Trace …
Long way back, we had to take help from third party tools in order to encrypt and decrypt data.  Gradually Microsoft understood the need for this feature and started to implement it by building functionality into SQL Server. Finally, with SQL 2008, …
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

710 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