SQL Import: importing data into SQL server from csv - sql-server

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.

Related

SSIS import access text to SQL Server in varchar (not nvarchar) format

Currently I want to manually import all tables (60+) in an access (2016) accdb file to SQL Server. Then I will truncate all those tables and build a SSIS job to load them to SQL Server (truncate table and full load) daily.
I created a new database in SQL Server. When I manually import all tables from access to the new database in SQL Server, I notice all text columns in those tables turn to be nvarchar. Actually I need them to be varchar.
Do I have to change table structure for all those columns in SQL Server or it there any easy way when I import data, I can convert it to varchar?

Import Varbinary(max) data using SQL Server/SSIS Data Import Wizard?

Is it even possible to import .csv flat file data into a SQL Server 2014 table using only the SSMS or SSIS Import/Export Wizards, if the table contains a varbinary(max) column?
I have searched hours and hours, and tried numerous configurations and different data types (e.g. DT_IMAGE) in both the SSMS and SSIS Import/Export Wizards to perform a simple, quick-n-dirty import of .csv file data into a four column table containing a varbinary(max) column in SQL Server.
I realize there are various other means to accomplish this by writing Trans SQL, using bulk-copy, adding column-import tasks, etc., but I find it hard to believe that I can't use the simple point-n-click configuration of the Import/Export Wizard, simply because the data happens to contain a varbinary(max) field, so I assume I must be doing something wrong.
Below are screen shots from the SSMS Import/Export Wizard...I get the same error in both SSMS and SSIS:
You can use DT_TEXT An ANSI/MBCS character string with a maximum length of 2^31-1 (2,147,483,647) characters.
Integration Service Data types.
It Will be varbinary(max) in database.
I have used the sample data provide by you and imported it in the database.

How to convert FoxPro data into SQL Server and keep the data type right?

I am importing FoxPro database to SQL server. I used MS SQL Server FoxPro Import, Export & Convert Software to convert and import the data into my SQL Server. It succeeded, but the data type of each column has changed to varchar(8000). Is there any better method to import FoxPro Database into SQL server and keep the data type of the imported data right?
I don't find a direct solution for the problem. Here is my work-around.
Import all the data from foxpro to sql server.
Create one more set of tables (with new names)
Copy and cast the data from old tables to new tables, something like: INSERT INTO SELECT CAST(col as your wanted data type) FROM
You could also try DBF Commander Pro's Export to DBMS feature. It converts field type during the export process. Choose 'Create new table' item as a destination table:

SQL Server Import - Weird number

I've imported some data into SQL server using the data import/export tool.
I'm exporting from a .xls workbook to SQL Server 2012.
The issue is that two fields, containing large(ish) numbers have been imported in a weird format.
Original Data:
532842549
What SQL Server Shows (Or Similar)
1.8327e+006
So far I have tried formatting the cells in excel to text, number + general but nothing seems to work.
Is there a way I can cast this value directly in SQL server back to the original value?
The destination field is a varchar(50) field.
I tried exporting Excel data to MSSQL Server and it went smooth. See the following steps.
Created a file with following data.
Went to MSSQL Server and started Imported Data. Right Click on Database => Tasks => Import Data ...
On column mappings step of conversion wizard, I changed type to bigint.
It's done. Check the final output.

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...

Resources