SQL Compare table with .txt file - c#

I have a table in SQL table name- Master which have Million of records and have Child1.txt file which have data. I have to remove the data from Master table which are not present in Child1.txt file. I am able to do it using import Child1.txt to temporary table and use left join.
The Problem is when I get Multiple .txt files eg. Child1.txt, Child2.txt, Child3.txt - Maximum allowed is 3 text file. The solution I came across is to use bulk insert by creating a temporary table and import all the 3 text files and compare with the master table.
I wanted to know if there was any other feasible solution to work on ????

Related

Import from .csv to sqlite

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

Automate the process of exporting data from multiple CSV files in a folder

I have already written a script to export data from a single CSV file into SQL Server. I do have to provide the path for that CSV.
I'm trying to figure out how do I modify the code so that it checks a particular folder for CSV files, and then starts processing them one by one. After processing each file, it moves the original file to a different location. Thanks in advance.
Update:
I have a console application written that parses the CSV, connects to SQL database and inserts values. But like I said I have to give the file path. I'm looking for a way to provide only a folder name and the application should look for any CSV files in that folder, parses each file, exports data to SQL, once done moves that file to a different folder and then starts with the next file.
For migrate data from csv try bulk insert
http://msdn.microsoft.com/ru-ru/library/ms188365.aspx
For example
bulk insert [tableName] from 'c:\test.csv'
With (
FIELDTERMINATOR =',',
FIRSTROW=1
)

import the updated excel value to database

I have a large amount of data in a excel sheet which has about 2000 rows. I have imported the table in sql server with no error.
I have to modify the excel now and update the same changes in the database also.
I cant delete the table and import again since i have large amount of data and have extra columns added to it.
So Please help me how to update the new values along with the existing values. I use C#.Net.
Thanks
Import into a temp table and then use the MERGE statement to update your master table.

Bulk Insert Querying to import data from text file to a database table

I have a text file with 25 fields, delimited with a pipe symbol.
Now, I have created a console application to import this text file data into the database table. In my database table, I have only 10 columns, and the user will choose the 10 columns from the 25 columns. So I have to import the specific 10 fields chosen by the user into the database. I am using the bulk insert query to import the text file into a temp table in my console application.
Now, how do I import only the user-chosen 10 columns from the text file to database table?
How do I modify the bulk insert query to achieve this?

LINQ : saving files to a database

I want to save a pdf and mp3 file(s) to a SQL Server database and be able to retrieve from it.
I'm still starting out with LINQ and don't master it yet.
You need to convert these into byte arrays (System.Data.Linq.Binary). One line to load
var myMp3 = new Binary(File.ReadAllBytes(mp3Filename));
If you create your database schema (VarBinary in the database) and drag the table over from Server Explorer into the DBML designer, it'll do everything for you.
To start off with your going to have a binary field in your database to save the file to.
Are you using LinqToSql, EntityToSql, or? Need some more information...
But once you get an object with a []byte to save the file to then it just a matter of making the appropriate Save() call... but with having some more information it hard to say.
Did you google tutorials?
Here is one that I found: Uploading Binary files or Images using LINQ to SQL
Has example code and sql to generate dummy tables...

Categories

Resources