dbTalk Databases Forums  

Delete database records based on EXCEL file

microsoft.public.sqlserver.dts microsoft.public.sqlserver.dts


Discuss Delete database records based on EXCEL file in the microsoft.public.sqlserver.dts forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
AJ
 
Posts: n/a

Default Delete database records based on EXCEL file - 11-05-2003 , 03:55 PM






I have a SQL table where every record needs to be deleted
unless the record is listed in an EXCEL spreadsheet. I am
thinking that DTS is the way to go. I have used dts to
export and import data, but haven't tried anything like
this. Does anyone know if this is possible to do or how
to do it?

Thanks,
AJ

Reply With Quote
  #2  
Old   
Sue Hoegemeier
 
Posts: n/a

Default Re: Delete database records based on EXCEL file - 11-05-2003 , 07:29 PM






One option is to do something like:
DELETE FROM SQLTable
WHERE NOT EXISTS
(SELECT *
FROM
OPENROWSET('Microsoft.Jet.OLEDB.4.0',
'Excel 8.0;Database=D:\YourExcel.xls', SheetName$)
AS Excel
WHERE Excel.IDColumn = SQLTable.IDColumn)

-Sue

On Wed, 5 Nov 2003 13:55:40 -0800, "AJ" <amrooney1 (AT) aol (DOT) com>
wrote:

Quote:
I have a SQL table where every record needs to be deleted
unless the record is listed in an EXCEL spreadsheet. I am
thinking that DTS is the way to go. I have used dts to
export and import data, but haven't tried anything like
this. Does anyone know if this is possible to do or how
to do it?

Thanks,
AJ


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.