Showing posts with label sever. Show all posts
Showing posts with label sever. Show all posts

Monday, March 26, 2012

How to insert a datetime to sql sever

Hi everyone,

I need help in inserting a date time string to sql sever. For example, how do you insert textbox1.text="2006-08-30 09:00:00" into a datatable column names starttime (type datetime) in sql sever? How do I covert the format of this string before I do the insert?

Thanks.

a123.

You don't have to pass that value. In the colum starttime set the data type to 'starttime' then for the default value enter getdate()

That should fix your problem.

|||

That would be an acceptable format (YYYY-MM-DD HH:mm:ss), of course you lose the sub-second precision though. If you always want to insert the current datetime, then as the previous poster said, change your insert statement to use getdate() rather than take the value from a passed parameter.

How to insert a datetime into sql sever

Hi everyone,

How do you insert this string value lable1.text="2006-08-30 09:00:00" into a data column like startdate (type: datetime) in sql sever?

How do I convert this string value before I insert it into sql sever?

Thank you very much.

a123.

Here is a quick sample:

using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["Conn2000"].ConnectionString))
{
conn.Open();
SqlCommand cmd = new SqlCommand("INSERT INTO tbl_dt (dt) SELECT @.dt", conn);
cmd.Parameters.Add("@.dt", SqlDbType.DateTime).Value = DateTime.Parse(TextBox1.Text);
cmd.ExecuteNonQuery();

}

Monday, March 12, 2012

how to import Excel spreedsheet to SQL Sever 2005

is there any easiest way to do it? thanks!

There are several possibilities.

Here is a resource that will guide you through them so that you can select the one that best fits your need: (The focus of the resource is to move data out to Excel, but the process is virtually the same to move data in from Excel.)

Export data to Excel
http://www.mssqltips.com/tip.asp?tip1202

|||

Have you tried that at express version.

Or is it only me .

If it works does anybody know good link for a noob.