You are here: Re: Skip rows where the first column with letter 'S' - BCP « MsSQL Server « IT news, forums, messages
Re: Skip rows where the first column with letter 'S' - BCP

Posted by Ed Murphy on 08/09/06 19:08

On 9 Aug 2006 08:16:02 -0700, ntuyen01@yahoo.com wrote:

>I have this data file with fix length(see below). I am able to insert
>it into the database using bcp, but now I want to skip (do not insert)
>the row which start with letter 'S' into the database. Is there away to
>do it? By the way I am using -F2 option to skip the first record.
>
>Here is my data:
>Record 1 04
> XXX
>2 13106900240120042003040045061 Testing N POLYDOROS TRUST
> EEE
>2 12621241640280041004040045633 What are they MARTIN &
> XXXXX
>S C10000032004004098500000596110000005000010000000019613000000576497500
>S X10000032000002098500000596130000000000000000000019613000000573497000

1) Create a new table with the same structure as your existing one,
plus an extra column to store the first character (if needed).

2) Give the new table trigger logic on insert/update to copy its data
to the original table iff the first character is not 'S'.

3) Use bcp to insert into the new table.

Alternatively, strip out the S lines ahead of time, e.g. install
ActivePerl and then do

while (<>) {
print "$_" unless $_ =~ /^S/;
}

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация