Do you always prefix SQL stored procedure names with the owner in ADO.NET code?
Last updated by Brady Stroud [SSW] 7 months ago.See historyStored procedure names in code should always be prefixed with the owner (usually dbo). This is because if the owner is not specified, SQL Server will look for a procedure with that name for the currently logged on user first, creating a performance hit.
SqlCommand sqlcmd = new SqlCommand(); sqlcmd.CommandText = "
proc_InsertCustomer" sqlcmd.CommandType
= CommandType.StoredProcedure; sqlcmd.Connection = sqlcon;
Bad example
SqlCommand sqlcmd = new SqlCommand(); sqlcmd.CommandText = "
dbo.proc_InsertCustomer"; sqlcmd.CommandType
= CommandType.StoredProcedure; sqlcmd.Connection = sqlcon;
Good example
We have a program called SSW Code Auditor to check for this rule.