Difference between Parameters.Add(string, object) and Parameters.AddWithValue

There is no difference in terms of functionality. In fact, both do this: return this.Add(new SqlParameter(parameterName, value)); The reason they deprecated the old one in favor of AddWithValue is to add additional clarity, as well as because the second parameter is object, which makes it not immediately obvious to some people which overload of Add …

Read more

Inserting into Oracle and retrieving the generated sequence ID

Expanding a bit on the answers from @Guru and @Ronnis, you can hide the sequence and make it look more like an auto-increment using a trigger, and have a procedure that does the insert for you and returns the generated ID as an out parameter. create table batch(batchid number, batchname varchar2(30), batchtype char(1), source char(1), …

Read more

Query runs fast, but runs slow in stored procedure

OK, we have had similar issues like this before. The way we fixed this, was by making local parameters inside the SP, such that DECLARE @LOCAL_Contract_ID int, @LOCAL_dt_From smalldatetime, @LOCAL_dt_To smalldatetime, @LOCAL_Last_Run_Date datetime SELECT @LOCAL_Contract_ID = @Contract_ID, @LOCAL_dt_From = @dt_From, @LOCAL_dt_To = @dt_To, @LOCAL_Last_Run_Date = @Last_Run_Date We then use the local parameters inside the SP …

Read more