How to import data from excel to sql server 2005
-
I want to import data from excel to sql server 2005. I am using C# for this purpose. I successfully exported the data of general format to varchar. But, the problem arises while exporting the data of date type. I have used date format in excel and want to export it in sql server 2005's datetime field. The code that I have used is:- SqlBulkCopy sqlBulk = new SqlBulkCopy(strConnection); sqlBulk.DestinationTableName = "Data_Master_Inventory"; sqlBulk.ColumnMappings.Add("VendorRegistrationNo", "VendorRegistrationNo"); sqlBulk.ColumnMappings.Add("ProductCode", "ProductCode"); sqlBulk.ColumnMappings.Add("SerialNo", "SerialNo"); sqlBulk.ColumnMappings.Add("VendorProvidedSerialNo", "VendorProvidedSerialNo"); sqlBulk.ColumnMappings.Add("ModelName", "ModelName"); sqlBulk.ColumnMappings.Add("ProductCategoryCode", "ProductCategoryCode"); sqlBulk.ColumnMappings.Add("InventoryDate", "InventoryDate"); sqlBulk.WriteToServer(dReader); Please provide me necessary solution.
-
I want to import data from excel to sql server 2005. I am using C# for this purpose. I successfully exported the data of general format to varchar. But, the problem arises while exporting the data of date type. I have used date format in excel and want to export it in sql server 2005's datetime field. The code that I have used is:- SqlBulkCopy sqlBulk = new SqlBulkCopy(strConnection); sqlBulk.DestinationTableName = "Data_Master_Inventory"; sqlBulk.ColumnMappings.Add("VendorRegistrationNo", "VendorRegistrationNo"); sqlBulk.ColumnMappings.Add("ProductCode", "ProductCode"); sqlBulk.ColumnMappings.Add("SerialNo", "SerialNo"); sqlBulk.ColumnMappings.Add("VendorProvidedSerialNo", "VendorProvidedSerialNo"); sqlBulk.ColumnMappings.Add("ModelName", "ModelName"); sqlBulk.ColumnMappings.Add("ProductCategoryCode", "ProductCategoryCode"); sqlBulk.ColumnMappings.Add("InventoryDate", "InventoryDate"); sqlBulk.WriteToServer(dReader); Please provide me necessary solution.
Please don't cross-post.