dbTalk Databases Forums  

How to identify data between two delimiters and insert it into a file using vb script

microsoft.public.sqlserver.dts microsoft.public.sqlserver.dts


Discuss How to identify data between two delimiters and insert it into a file using vb script in the microsoft.public.sqlserver.dts forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Ajay Garg
 
Posts: n/a

Default How to identify data between two delimiters and insert it into a file using vb script - 01-05-2004 , 01:02 PM






I am new to vb scripting and was looking for a way to look up a file
and identify all the charachters between two delimiters and insert
them into a field of a table.The file is having data limited by
hex(07) delimiters and i am able to identify the first delimiter as
followws,How can i identify the data between 2 delimiters and insert
it into a table.


Thanks

Ajay


************************************************** ******************
' Visual Basic ActiveX Script
'************************************************* *******************
Function Main()

dim pipect,i,fld,c
dim column(50)

Set f1o = CreateObject("Scripting.FileSystemObject")
Set f1 = f1o.OpenTextFile("T:\Load to SQL\testfile.txt" , 1)

Do Until f1.AtEndOfStream
c = f1.Read(1)
msgbox "value of c" & c

if c = Chr(7) then
msgbox "found the delimiter"
end if
Loop
Main = DTSTaskExecResult_Success
End Function
=================================

Chr(7) is the character represented by x07

Reply With Quote
  #2  
Old   
Allan Mitchell
 
Posts: n/a

Default Re: How to identify data between two delimiters and insert it into a file using vb script - 01-06-2004 , 01:17 AM






Are you saying that you have a delimited text file?

Have a look at this.

Coping with text files and abnormal column or row delimiters
(http://www.sqldts.com/default.aspx?257)

--

----------------------------
Allan Mitchell (Microsoft SQL Server MVP)
MCSE,MCDBA
www.SQLDTS.com
I support PASS - the definitive, global community
for SQL Server professionals - http://www.sqlpass.org



"Ajay Garg" <ajayz90 (AT) hotmail (DOT) com> wrote

Quote:
I am new to vb scripting and was looking for a way to look up a file
and identify all the charachters between two delimiters and insert
them into a field of a table.The file is having data limited by
hex(07) delimiters and i am able to identify the first delimiter as
followws,How can i identify the data between 2 delimiters and insert
it into a table.


Thanks

Ajay


************************************************** ******************
' Visual Basic ActiveX Script
'************************************************* *******************
Function Main()

dim pipect,i,fld,c
dim column(50)

Set f1o = CreateObject("Scripting.FileSystemObject")
Set f1 = f1o.OpenTextFile("T:\Load to SQL\testfile.txt" , 1)

Do Until f1.AtEndOfStream
c = f1.Read(1)
msgbox "value of c" & c

if c = Chr(7) then
msgbox "found the delimiter"
end if
Loop
Main = DTSTaskExecResult_Success
End Function
=================================

Chr(7) is the character represented by x07



Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.