What is faster for multiple SQL calls — parameterized queries or stored procedures?

I am using SQL Server 2005. I am looking for opening an SQL connection, looping the collection and running the update request (stored procedure or parameterized query) with the data from the collection item, and then closing the connection.

What will give me the best performance and why?

+3
source share
6 answers

It’s hard to say with certainty, since there are a number of factors that can affect performance. Theoretically, the stored procedure method should be faster.

, XML , . , , XML. Xquery, Open XML sp_XML_preparedocument XML .

+3

SQL- . , .

.

, ( 1 2), . .

" proc", , . LINQ .

( ) , , . , , procs ( ) .

+10

. , , , , , . , , DBA, , , , , , .

+3

- . , , . , , . , , , SQL , . , SQL, .

+2

( ), , .

, :

  • SqlCommand /.
  • SqlParameter , , Parameters .
  • Prepare .
  • , .
+2

Usually stored procedures because the server can pre-optimize the execution plan. Although a well-written parameterized query is better than a general stored procedure.

-1
source

Source: https://habr.com/ru/post/1706004/


All Articles