Eliminate and reduce overlapping date ranges

For SQL Server 2005+ — sample table with data declare @t table(UserID int, StartDate datetime, EndDate datetime) insert @t select 1, ‘20110101’, ‘20110102’ union all select 1, ‘20110101’, ‘20110110’ union all select 1, ‘20110108’, ‘20110215’ union all select 1, ‘20110220’, ‘20110310’ union all select 2, ‘20110101’, ‘20110120’ union all select 2, ‘20110115’, ‘20110125’ — your … Read more

Passing parameter to stored procedure in C#

you can try this code : bool result=false; SqlCommand scCommand = new SqlCommand(“usp_CheckEmailMobile”, sqlCon); scCommand.CommandType = CommandType.StoredProcedure; scCommand.Parameters.Add(“@Name”, SqlDbType.VarChar, 50).Value = txtName.Text; scCommand.Parameters.Add(“@Email”, SqlDbType.NVarChar, 50).Value = txtEmailAddress.Text; scCommand.Parameters.Add(“@Password “, SqlDbType.NVarChar, 50).Value = txtPassword.Text; scCommand.Parameters.Add(“@CountryCode”, SqlDbType.VarChar.50).Value =ddlCountryCode.SelectedText; scCommand.Parameters.Add(“@Mobile”, SqlDbType.NVarChar, 50).Value = txtMobileNumber.Text; scCommand.Parameters.Add(“@Result “, SqlDbType.Bit).Direction = ParameterDirection.Output; try { if (scCommand.Connection.State == ConnectionState.Closed) { scCommand.Connection.Open(); } … 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