I just wonder if there is a way to specify query hint while calling a stored procedure using SQLCommand object?
For example, I need to call something like this
EXECUTE SPName'0068', 40 WITH RECOMPILE
I just wonder, how I can simulate this using SQLCommand object.
Dim connection As New SqlClient.SqlConnection("server=(local);database=DEV;Persist Security Info=True;uid=sa;pwd=;")
connection.Open()
Dim cmd As New SqlClient.SqlCommand
With cmd
.Connection = connection
.CommandText = "Warehouse_AdjustInventory_byWarehouse_u"
.CommandType = CommandType.StoredProcedure
.Parameters.AddWithValue("@ProductID", "0068")
.Parameters.AddWithValue("@WarehouseID", 40)
End With
Try
Dim result As Integer = cmd.ExecuteNonQuery()
Trace.WriteLine(result)
Catch ex As Exception
Trace.WriteLine(ex.Message)
End Try
connection.Close()
Does SQLCommand support to supply query hints like With RECOMPILE? thank you
WITH RECOMPILE? This will make your stored procedure slower. If the stored procedure uses inefficient techniques like changing WHERE predicates, it would be better to fix the query. If you want the stored procedure to recompile all the time, just add theWITH RECOMPILEclause to its definition