Mohan Chandra

Mohan Chandra

  • NA
  • 101
  • 17.1k

How we can validate excel data before import in SQL by using

Jul 9 2016 5:19 AM
How we can validate excel data before import in SQL by using 
 
I need a solution that my client give the master data in excel sheet old + new data) it is difficult to find which one is new data, and even some data is updated with same Receipt No,which is already in SQL but not updated.
now give me solution how i can validate data when file upload control picks that excel sheet for uploading.


I want to try when an new excel sheet comes by client, client upload it to SQL by using file upload control but it should be validate first.if new entry come then it should be insert and if old record already in SQL then skip and if updated row comes then update in SQL server

Answers (2)

0
Nilesh Sawardekar

Nilesh Sawardekar

  • 404
  • 3.9k
  • 397.2k
Jul 10 2016 3:18 AM
Two solutions
  1. Do work in coding using for loop and if else and then insert in database.(time consuming if data is huge but may not if you know row numbers.)
  2. Create temp data and add whole data and then manipulate.
0
Nitin Sontakke

Nitin Sontakke

  • 135
  • 13.6k
  • 14.9k
Jul 9 2016 11:55 PM
What do you want to do everything in one go?
You can simply import the Excel data to SQL Server (which you know how to do) and put that data in some staging table.
And then from staging table move to your main table using MERGE statement.