urgent please

  • we will be getting data in flatfiles and before transferring it into server i need to check

     if the flatfile has errors in it. i mean we need to check each and every position and if

     it has error it should be transferred into another file.

    01XYZ234     27838378278     12   20050912

    the position of first field is 1-2

                    second field is 3-13.......so on

    seeing the positions i need to test that if the first field has anything other than 01

     its an error. similarly it should check for each and every field.

    i need to write a SP for this. will be great if anyone can help me out with this problem. i

    am confused of what to do

  • What I usually do for stuff like this is dump all the data into a temp table. Once you get your data there you can transfer the data that is "offensive" and put it in another table for review, or outputed to file... Then do your stuff with the good data.

  • yeah i did it same way .after doing this operation i will be getting the table with no errors in it. but what i want is

    i want to transfer the table with no errors into new table and delete the data in the old table

    so that everytime i get the data with the code 01 it transfers it into old table and continue with the same operation.

    can u lat me know if u didnt understand what i am talking about.

  • It's pretty much the same thing I said. What else do you need to know?

  • i have transferred the fields with errors in a temp table and deleted the fields with errors in the main table.

    but now what i want is i need to transfer this data which is in the new table (with no errors) into another temp table

    and delete data in the new table, so that if i get the data with 01 records it again uses the same old table and does the same operation.

    sorry if i am confusing u.

  • You need the syntaxe to do the insert??

    Insert into dbo.NewTempTable (Col1, col2...) Select Col1, Col2 from dbo.tempTable1

    truncate tempTable1 to empty the main temp table.

  • declare @record_code char(2)

    select * from record001

    where record_code not in ('00','01','02','03','04')

     if(@record_code='00')

    begin

     insert into record0

     select * from record001

      where agency is null

      or trans_id is null

      or ISNUMERIC(trans_id)=0

      or isnumeric(accounts_trans)=0

      or isnumeric(baccounts)=0

      or isnumeric(daccounts)=0

      or isnumeric(osa)=0

     delete record001

     where agency is null

      or trans_id is null

      or ISNUMERIC(trans_id)=0

      or isnumeric(accounts_trans)=0

      or isnumeric(baccounts)=0

      or isnumeric(daccounts)=0

      or isnumeric(osa)=0

    if (@@error=0)

    delete record001

    end

    this is the sample code which i have. not getting the correct solution if i run this.can u just check it out.

    this is what i need..need to check if the record code is either 00,01,02,03,04.and if it is 00 it should do the operation. can u please help me out

  • Can you post the table definition, some sample data. And what you are trying to accomlish

    col1, col2, col3

    1,2,3 >>move to tableV

    1,2,4 delete if

    4,6,9 >>move to tableY

  •  

    thanks for ur help

    hi the table has the data like this.first two positions represent record id, [3-8]represent internal id and next acct,code,date

    01XYZ234     27838378278     12   20050912

    00XYZ234     27838378278     12   20050912

    the record id can be either 00,01,02,02,04

    what i need to do is if the record id is 00 then i need to do the following above mentioned operation. means i need to check for the record id first and then do the next step.

     

  • insert into record0

    select * from record001

    where

    left(FirstCol, 2) = '00' AND

    (

    agency is null

    or trans_id is null

    or ISNUMERIC(trans_id)=0

    or isnumeric(accounts_trans)=0

    or isnumeric(baccounts)=0

    or isnumeric(daccounts)=0

    or isnumeric(osa)=0

    )

  • hey remi thanks a lot for ur help. really appreciate for what u did till now

  • ...untill now

    Need anything else?

  • HEY I HAVE RECORS WITH CODE

    00

    00

    00

    01

    05

    01

    03

    05

    00

    I NEED A COUNT OF EACH RECORD. I MEAN COUNT OF 00,01,03,05.HOW DO I QUERY THIS

  • Select left(CodeCol, 2) as CodeType, count(*) as Total from TempTable

    Group by left(CodeCol, 2)

  • hi i have a question

    i have a sample code which will find the errors in the main file and puts those errors into

    the error table.

    i have created a dts package for this and am calling global variables so that i can use it

    for different files

    hear i have a problem, this package is running well. i need to connect this package(execute

    package task) to another package.

    if the package which i have created has errors my code will put it in errortable and what

    i want is if it has errors it should not process the next package. if not it should process

    the next package

    will be thankful if anyone can help me out

Viewing 15 posts - 16 through 30 (of 30 total)

You must be logged in to reply to this topic. Login to reply