Solved

Help with sp_executeSQL calling a stored procedure with multiple parameters

Posted on 2014-01-23
4
487 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

I have written a PowerShell script to "walk" the security structure of each SQL instance to find:         Each Login (Windows or SQL)             * Its Server Roles             * Every database to which the login is mapped             * The associated "Database User" for this …
If you have heard of RFC822 date formats, they can be quite a challenge in SQL Server. RFC822 is an Internet standard format for email message headers, including all dates within those headers. The RFC822 protocols are available in detail at:   ht…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…
I designed this idea while studying technology in the classroom.  This is a semester long project.  Students are asked to take photographs on a specific topic which they find meaningful, it can be a place or situation such as travel or homelessness.…

947 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

22 Experts available now in Live!

Get 1:1 Help Now