SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Tab Delimited file handling


Tab Delimited file handling

Author
Message
New Commer
New Commer
Old Hand
Old Hand (370 reputation)Old Hand (370 reputation)Old Hand (370 reputation)Old Hand (370 reputation)Old Hand (370 reputation)Old Hand (370 reputation)Old Hand (370 reputation)Old Hand (370 reputation)

Group: General Forum Members
Points: 370 Visits: 467
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 !
New Commer
New Commer
Old Hand
Old Hand (370 reputation)Old Hand (370 reputation)Old Hand (370 reputation)Old Hand (370 reputation)Old Hand (370 reputation)Old Hand (370 reputation)Old Hand (370 reputation)Old Hand (370 reputation)

Group: General Forum Members
Points: 370 Visits: 467
Hi ! No one to help me ?? Sad
Chris Hurlbut
Chris Hurlbut
SSCommitted
SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)

Group: General Forum Members
Points: 1850 Visits: 540
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.
Chris Hurlbut
Chris Hurlbut
SSCommitted
SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)

Group: General Forum Members
Points: 1850 Visits: 540
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]('aaa aaa aaa ',char(9) )
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search