Tab Delimited file handling

  • Hi,

    I am new to Integration Services technology.

    In SQL 2008 R2 Integration Services, We will be given Tab delimited Text files with million rows of records. I am in need to write a script to check the fields count againts the table fields count and have to separte the records which are not matching.

    i.e. The records all are in need to be inserted into a table which will have a fixed number of fields. lets say 10.

    Before inserting the records a validation has to be done for checking each record for the same count of fields(COLUMNS). The records which were not having the exact match are needed to get those records as separate output file

    I need any of your help in start writing the script which is completely new to me.

    Thanks !

  • Hi ! No one to help me ?? 🙁

  • Hello Here is one way.

    Create Flat file Connection in SSIS setting the layout for 1Col

    Create SQL Table:

    CREATE TABLE dbo.Process_Table (

    ID int identity(1,1) not null,

    Column1 varchar(5000) null,

    Nbr_Fields int null)

    Import the whole record into the Process_Table field Column1

    Update the nbr_Fields based on counting how many tabs there are in the record

    Parse all the records that contain the correct number of fields into the appropriate table

    Then you will also have all the records that didn't pass the validations, once the records are imported to the database table, you should be able to parse the records using SQL (substring to parse each column)

    I didn't give you specifics as this should be relatively easy to do, writing the sql will be the most time consuming, any questions just reply to this thread and I will Help.

  • Here is a function that you can use to count the tabs in a records:

    --create this function first

    CREATE FUNCTION [dbo].[ufn_CountChar] ( @pInput VARCHAR(1000), @pSearchChar CHAR(1) )

    RETURNS INT

    BEGIN

    RETURN (LEN(@pInput) - LEN(REPLACE(@pInput, @pSearchChar, '')))

    END

    GO

    --counts the nbr tabs in string

    PRINT [dbo].[ufn_CountChar]('aaaaaaaaa',char(9) )

Viewing 4 posts - 1 through 3 (of 3 total)

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