Please start any new threads on our new site at We've got lots of great SQL Server experts to answer whatever question you can come up with.

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
Register Now and get your question answered!
Save Password
Forgot your Password?

 All Forums
 SQL Server 2008 Forums
 SSIS and Import/Export (2008)
 Insert rows
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Aged Yak Warrior

623 Posts

Posted - 12/11/2012 :  16:35:51  Show Profile  Reply with Quote
I have requirement to load the data in respective table from the
excel file.

The excel file has status which states the record to added,modify,delete for a employee.

Sample Excel file data

status customerid name city
------ ------------ ------ ------
Add 10000 test SFCO
Modify 10001 test1 NY
Delete 10001 test3 DC

Please let me know know best way to do it.

Flowing Fount of Yak Knowledge

5155 Posts

Posted - 12/11/2012 :  17:25:42  Show Profile  Reply with Quote
The simplest way I can think of is to load the data from the Excel file into a Work Table and then write a query to Add/modify/delete. To delete the following, and similar code for Insertions and updates
FROM YourRealTable y 
	SELECT * FROM YourWorkTable w
	WHERE w.customerid = y.customerid
	AND w.status = 'Delete'
You can use SSIS to insert and to run the update queries.
Go to Top of Page

Very Important crosS Applying yaK Herder

52326 Posts

Posted - 12/14/2012 :  03:04:42  Show Profile  Reply with Quote
in ssis you can use conditional task to define outputs based on status column value in dataflow task and write corresponding logic (insert/update/delete) in relevant output branches. Use OLEDB command for update and delete and then OLEDB destination for insert.
If number of rows is really huge, consider doing update in update/delete branches to set bit value to indicate records to be deleted/updated and then follow up with execute sql tasks in control to do batch update and deletes. Also for insert set fast load option for OLEDB destination

SQL Server MVP

Go to Top of Page
  Previous Topic Topic Next Topic  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.04 seconds. Powered By: Snitz Forums 2000