dbTalk Databases Forums  

How to skip the last n records in a text file while loading

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


Discuss How to skip the last n records in a text file while loading in the microsoft.public.sqlserver.dts forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
karenmiddleol@yahoo.com
 
Posts: n/a

Default How to skip the last n records in a text file while loading - 10-19-2005 , 03:40 PM






I want to skip the last n records which could be last 3 or 4 records.

How can I do this.

Thanks
Karen


Reply With Quote
  #2  
Old   
Ilya Margolin
 
Posts: n/a

Default Re: How to skip the last n records in a text file while loading - 10-21-2005 , 08:36 AM






Karen,

You can do it in two different ways. You can create a staging table with an
identity column, load into it, and delete 3 rows with the identity greater
then count(*) - 4. Or you can open the file with File System Object, get the
number of rows, and specify Last Row in your Data Pump/Bulk Load Task.

Ilya

<karenmiddleol (AT) yahoo (DOT) com> wrote

Quote:
I want to skip the last n records which could be last 3 or 4 records.

How can I do this.

Thanks
Karen




Reply With Quote
  #3  
Old   
Thomas Bradshaw via SQLMonster.com
 
Posts: n/a

Default Re: How to skip the last n records in a text file while loading - 10-21-2005 , 08:44 AM



Karen,

First, I would load the entire file into a table that contains an IDENTITY
column.
After that I would use an 'Execute SQL task' to delete the last 4 rows in the
table. Something like:

DELETE DestTable
WHERE IdColumn IN
( SELECT TOP 4 IdColumn
FROM DestTable (Nolock)
ORDER BY IdColumn DESC )

Let us know how you make out.

Thomas Bradshaw
MyWebGrocer.com
Data Integration Services


--
Message posted via http://www.sqlmonster.com

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.