I am using sqlite to create a Database with table which has to be just like the csv file along with the headers and data.
what is the best way to create a table in the sqlite database with schema and data from the .csv file.
can i avoid writing the script for the CREATE table?
Thank you in advance!!
I've used SQL Server Import and Export Wizard in the past for creating simple tables from a file. It can automatically detect data types and create the table.
http://technet.microsoft.com/en-us/library/ms141209.aspx
Related
I have an MS Access file with multiple sheets having different types of data. I want to read data from the file's sheets and insert it into corresponding SQL Server Database Tables either using T-SQL or SSIS. I am trying to learn these concepts and any help would be appreciated!
I've tried exporting a table which it has 5 TEXT columns and 1 BLOB column, this last column is used for storing images.
But, when I export the database table into a csv file (by using the software SQLite Database Browser) the information of this columns is transformed into TEXT as well. (Perhaps I was wrong)
How can I export BLOB data from my sqlite db table to a sql server table?
I will be so thankful if you help me. Please!! (I'm programming a c# application, but It doesn't matter, because I'm using SQLite Database Browser 2.0 b1.exe to see the data.)
Is there a way to import data from an excel sheet into a database on SQL Server without using the bulk method? Keeping in mind that I'm creating a web application where the user uploads an excel file to the page and it proceeds to import it into an existing database.
The bulk method works using OleDbDataReader, except it copies the excel sheet and pastes it onto the database without considering the column names compatibility. Am I missing something?
If you are working through SSMS, use the SQL Import Export Wizard. There's enough documentation on MSDN
From code you can use the SqlBulkCopy class for importing into SQL databases. If you are importing bulk records into Oracle you can use ODP.net OracleBulkCopy. Oracle bulk copying is only supported right now through the full ODP.net provider. Managed ODP.net does not support bulk operations.
To read the Excel file you can use any number of libraries.
LinqToExcel,
OleDb,
closedxml
Take a look at the DocumentFormat.OpenXml.Spreadsheet namespace: MSDN Link
It will let you look at the different parts of the spreadsheet as it is stored in OpenXML.
You can use format file along with bulk insert. The format file maps between table columns and the fields in the file.
Refer :
https://learn.microsoft.com/en-us/sql/relational-databases/import-export/use-a-format-file-to-bulk-import-data-sql-server
Is it possible to save a csv file to a SQL Server Database table using C#?
Do need to convert the csv file to Binary format in order to do this?
Is there any other way, like saving it in text format(csv is a basically a txt file)?
I'd appreciate it if you could provide some example code.
CSV files are just text. You can create a table that has an nvarchar(max) column and store your CSV files in there.
You have another helpful C# sample for import and export of CSV file with SQL Server. Below is the link:
http://www.codeproject.com/Articles/30705/C-CSV-Import-Export
You can use the data import wizard I believe and point it at a csv file. This should create a table that matches the structure of your imported csv
I am making a window application in asp.net using C#. I want to browse and import .csv file and save it in the database. Importing part I have done. Now, how am i supposed to save it in the database ? I am new to the language so please help
You can use ADO.NET, you will need to look up Data Adapters and the like.
If your Importing the Spreadsheet into a DataTable or DataSet you can use a Data Adapter to populate a table in the Database using an INSERT command.
Look up http://msdn.microsoft.com/en-us/library/system.data.common.dataadapter.aspx
Hope This Helps.
Once you have a file upload mechanism in place, (for example, using the FileUpload control), just iterate through the lines in the CSV file on the server, parse them into fields using an existing CSV reader (don't try to code your own unless your data is completely trivial, you won't handle all of the edge cases), and just execute a bunch of SQL INSERT statements against your database using your calling convention of choice.