Re: parsing txt file

From: Allan Mitchell (allan_at_no-spam.sqldts.com)
Date: 12/16/04


Date: Thu, 16 Dec 2004 21:32:23 -0000

Sure you can reset a Global variable whenever you want.

Does Branch = a global variable?

if it does then it needs to be DTSGlobalVariables("Branch").Value

This way would suggest you are reading the file anyway so you would not need
a global variables.

Personally if this was a common format for my files I would look to create a
custom task to do this. I would pass the filename and the destination table
to the task and from there my task would do the rest using VB.

-- 
Allan Mitchell MCSE,MCDBA, (Microsoft SQL Server MVP)
www.SQLDTS.com - The site for all your DTS needs.
www.SQLIS.com - You thought DTS was good.  here we show you the new stuff.
www.konesans.com - Consultancy from the people who know
"FRED" <FRED@discussions.microsoft.com> wrote in message 
news:503E2E94-6E3F-49B8-AA22-645E3E7F1577@microsoft.com...
>I see, but if there is a way to not reset the variable for each row I think 
>I
> could make it.
> something like
>
> If  DTSSource("Col002") = "36" then Branch = "9125"
>
> "Allan Mitchell" wrote:
>
>> I would read the file using VBScript to start with (or even use your
>> favourite language outside of DTS and pass in the value) and extract the
>> value for the branch number.
>> I would assign this value to a global variable
>> You can then assign the global variable to a destination column.
>>
>> Now back to structure.
>>
>> The problem with what you have here as I see it is that you have a number 
>> of
>> "files" in a file.  DTS will not like this at all.  Sure you can skip a
>> header but by the look of it you have many.
>>
>> You could choose to skip the next header rows by not inserting the row if
>> you see some text in that row but this will be remarkably clumsy.
>>
>> Personally I would either have the feed provider give you the feed 1 file
>> per Bracnh number or I would parse the file again using whatever you want
>> and write out your own text files for each branch and then loop over 
>> them.
>>
>>
>>
>> -- 
>>
>>
>>
>> Allan Mitchell MCSE,MCDBA, (Microsoft SQL Server MVP)
>> www.SQLDTS.com - The site for all your DTS needs.
>> www.SQLIS.com - You thought DTS was good.  here we show you the new 
>> stuff.
>> www.konesans.com - Consultancy from the people who know
>>
>>
>> "FRED" <FRED@discussions.microsoft.com> wrote in message
>> news:E5531CF2-D69B-463A-861A-E04C151BF2FF@microsoft.com...
>> >I created a DTS from a txt file and I transform the file to skip some 
>> >row
>> > with condition. The txt file is in fact a report that has header, 
>> > detail
>> > and
>> > footer and I'm importing only the detail part of the report but would 
>> > like
>> > to
>> > have part (the BRANCH number) of the header as a field. Here's the 
>> > sample
>> > report
>> >
>> > --------------------------------------------------------------------------------
>> > page1                             amortization report
>> > 12/10/2004
>> > for branch 9125                        bidon cie
>> >
>> > code        asset#      descr          dep meth     book val    dep val
>> > T             390000     Dell server   SLN            12,000.25 
>> > 4,500.35
>> > U             580000     Building       SLD            50,000.36
>> > 49,000.36
>> > .....
>> >
>> > page2                            amortization report
>> > 12/10/2004
>> > for branch 8237                        bidon cie
>> >
>> > code        asset#      descr          dep meth     book val    dep val
>> > T             391000     Workstation  SLN            2,000.25 
>> > 500.35
>> > U             588000     Loader         SLD            30,000.36
>> > 29,000.36
>> >
>> >
>> > End of the report
>> > -----------------------------------------------------------------------------------
>> >
>> > the data I want to insert are:
>> > char         char         char            char           reel
>> > reel       Branch
>> > T             390000     Dell server   SLN            12,000.25 
>> > 4,500.35
>> > 9125
>> > U             580000     Building       SLD            50,000.36
>> > 49,000.36
>> > 9125
>> > T             391000     Workstation  SLN            2,000.25 
>> > 500.35
>> > 8237
>> > U             588000     Loader         SLD            30,000.36
>> > 29,000.36
>> > 8237
>> >
>> >
>> > Thanks for your help
>>
>>
>> 


Relevant Pages

  • Re: Multiple text files to multiple tables
    ... > That's for bulk insert but if you really want to usr dts you can do a similar thing setting a global variable using dtsrun then using a dynamic properties task to set it as the source file. ... These subsequent SQL tables will then be queried to ... The batch file passes Global Variables to a DTS package that first ... .txt file to the staging table which works well. ...
    (microsoft.public.sqlserver.dts)
  • Re: Transform Data Task, parameterized SP: "No value given for one or more required parameters&
    ... Global Variables and SQL statements in DTS ... > exec ap_ds_getstagingdata 141, 'Points'> ... > The global variable ConversionID *is* defined, and has a default value> of 141. ...
    (microsoft.public.sqlserver.dts)
  • Re: DTS issue....please help!!
    ... > Allan Mitchell MCSE,MCDBA, ... > www.SQLDTS.com - The site for all your DTS needs. ... >>> Global Variables and Stored Procedure Parameters ... >>> SET NOCOUNT ON ...
    (microsoft.public.sqlserver.dts)
  • Re: Results in email
    ... You can then use this article to extract them into Global Variables ... Allan Mitchell MCSE,MCDBA, (Microsoft SQL Server MVP) www.SQLDTS.com - The site for all your DTS needs. ... I have a number of SQL updates that I have setup as Execute SQL Tasks. ...
    (microsoft.public.sqlserver.dts)
  • Re: DTS issue....please help!!
    ... Also the DTS package correctly assings a value to the ... > Global Variables and Stored Procedure Parameters ... >>I have a stored procedure that does a qc check on 2 tables. ...
    (microsoft.public.sqlserver.dts)