Configure SQL to Import Excel Files with Specific Datetime Format - sql-server

I have a few excel files (exported from very old SQL Server 6.5 database) that have datetime fields in this format:
DD/MM/YYYY HH:MM:SS
I wish to import these excel files into SQL Server 2014.
But, SQL Server 2014 accepts excel files with datetime format of:
YYYY/MM/DD HH:MM:SS.FFF
My excel files couldn't be imported. Currently, I'm doing the formatting manually through excel formulas, which is a very tedious process.
Is there a way to configure SQL Server 2014 to take in excel files with a specific datetime format?

Have you tried using the import wizard through tasks?
I have managed to import the described data format from excel files.
Via the Import wizard, once you get to the Source and detestation tab (Column Mappings), click edit mappings, make sure all your date fields from your excel SpreadSheet are set to type > "DateTime".
SQL then should import them correctly and then convert them into the YYYY/MM/DD HH:MM:SS.FFF format.

Related

Parse datetime in SQL Server with Time Zone information

I have a datetime taken from my system in the following format inside an Excel table: "2021-11-02 09:54:52 EDT". SQL Server can't parse the timezone.
Is there a way for SQL Server to parse this timezone or do I need to remove it from the CSV, or should I parse it in Excel?

Link Excel sheet to SQL Server

Is it possible to link an Excel sheet to a SQL Server database? I want to be able to join the Excel columns to the tables in SQL Server and run queries. I can find plenty of examples to link the tables from SQL Server to Excel, but I want the other way around.
Thank you in advance for any suggestions.
Use SQL Server Import and Export Wizard.
Set your worksheet as a Data Source
Excel file path
Specify the path and file name for the spreadsheet
from which to import the data. For example, C:\MyData.xlsx or
\Sales\Database\Northwind.xlsx. Or, click Browse.
Browse
Locate the spreadsheet by using the Open dialog box.
Excel version Select the version of Excel that is used by the source
workbook.

SQL Import: importing data into SQL server from csv

I have a table already stored in sql server with all the columns and the data type of the columns. I am now trying to import a txt file into sql server. But since all the fields are already in the string format, it is not able to import the data into the server. Is there any way to change the format of the datatype within the txt file to match that of the table within the sql server? The number of columns are 150 to import
You may need to look into creating a SSIS package and adding the data conversion tool to cast/convert the data being imported into the correct datatype.

SQL Server Importing Excel data ..Confusion in selecting the Datatype in Import and Export Wizard

The question is regarding SQL Server 2010 Import and Export Wizard. I am in a strange situation.
I am trying to import Excel data into my database. One of the columns in Excel is Part Number which can have values like (418138031, A1801354B).
Now in Import and Export Wizard -> at Edit mappings..if I select nvarchar datatype for the column... only values like A1801354B are imported to my database. If I select float datatype only values like 418138031 are imported to my database.
What should I do if I want to retrieve both types of values i.e. 418138031, A1801354B.
Please help me.
Thanks,
Vanu
This is an issue with the crappy excel (Jet) driver. My recommendation would be to save the file as a csv and use the flat-file source instead. Otherwise you have to wrestle with what the excel driver heuristics decide is the data type, and get the behavior you've described...

SSIS converts .csv date field to incorrect format on production SQL server

I am using SSIS 2005 to read data off a .csv file into a SQL Server 2005 Database. I am using a Flat File connection manager for the .csv and an OLEDB Connection Manager for the resulting rows.
The .csv file contains a field which is a date in UK format (dd/mm/yyyy), which may be written, say, 7/3/2011 for 7th March 2011. This column is then mapped onto the equivalent datetime field in the SQL Server database.
The problem I am facing is that, while everything works fine on the development machine, when used on the production environment, the dates get changed to US (mm/dd/yyyy) format (if valid), when they are inserted into SQL Server. Is there some place where the desired Region/Format (in this case UK) for the destination datetime field can be specified, maybe somewhere in the package or some setting on the production server itself?
Thanks in advance,
Tim
You can set the locale in the Flat File Connection Manager Editor or LocaleID in the Properties box for the connection (same thing). Setting it to "English (United Kingdom)" will interpret the dates correctly, because SSIS uses the locale in the package or data flow, not the OS locale.
Note that you have to set the format at the source, not the destination: datetime is a binary format in MSSQL so dates aren't stored internally in a locale-specific format anyway.

Resources