To solve the above we can do it in different ways. Sql Server provides us with a tool to solve it.
Sql Server Import and Export Wizard Download
Through the Import and Export Data tool we can bring the records that have a defined structure in a flat file and pass them to an Sql table.To open the tool we go to the Sql Managament Studio and on the database right click select Task -> Import data ... As the following image shows:
Or we can also execute the dtswizard command:
CSV To SQL
When executing the command or opening the option for the Sql Managament Studio, the following image is shown:
Post Popular
Then we select in Data Source: Flat File Source
Select the file (Browse ...) that we need:
To visualize the columns we select Row delimiter and the Column delimiter:
If we need to change the type of data or the size of the column we enter Advanced:
Then we click on Next, select the server where the data destination will be:
In the previous image we click on Next and we see the destination of the table that we are going to load, here we need it we can change the name:
Finally at this point we click on Next, if an incompatibility option appears
In the column data types, we select ignore and end.
We can check the database where the data was in the table we created and validate that everything is fine. This was an example of how to import csv files to sql.
No comments:
Post a Comment