dbTalk Databases Forums  

Parse for a numeric string using ActiveX in DTS

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


Discuss Parse for a numeric string using ActiveX in DTS in the microsoft.public.sqlserver.dts forum.



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

Default Parse for a numeric string using ActiveX in DTS - 03-17-2005 , 11:13 AM






Hello,

I'm trying to parse for a numeric string from a column in a table. What
I'm looking for is a numeric string of a fixed length of 8.
The column is a comments field and can contain the numeric string in
any position. I'm not familiar with ActiveX, so any suggestions will be
useful.

Thanks in advance.


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

Default Re: Parse for a numeric string using ActiveX in DTS - 03-17-2005 , 01:20 PM






Is the source SQL Server?

CREATE TABLE Jumble(col1 varchar(20))
INSERT Jumble VALUES('12345678ABC')
INSERT Jumble VALUES('AAAAAAAAAAA')
INSERT Jumble VALUES('AB12345678C')


select * FROM dbo.Jumble
where Col1 LIKE ('%[0-9][0-9][0-9][0-9][0-9][0-9]%')







"SQL_developer" <vlavanya (AT) gmail (DOT) com> wrote


Quote:
Hello,

I'm trying to parse for a numeric string from a column in a table. What
I'm looking for is a numeric string of a fixed length of 8.
The column is a comments field and can contain the numeric string in
any position. I'm not familiar with ActiveX, so any suggestions will be
useful.

Thanks in advance.


Reply With Quote
  #3  
Old   
SQL_developer
 
Posts: n/a

Default Re: Parse for a numeric string using ActiveX in DTS - 03-17-2005 , 01:32 PM



Thank you for the reply!
The source is SQL Server. The field I am trying to pull the data from
is a comments field.
Here's an example of the values in the column

1) Fri KX 3-21-98 5:48 P.M. arrival Cxled ATRI #27068935 3-17-98
2) wed.kx10/26 Netrez 95860536

Now I need to parse through these lines and return only the 8 digit
numbers in it
The result set should be

27068935
95860536


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

Default Re: Parse for a numeric string using ActiveX in DTS - 03-17-2005 , 01:56 PM



OK

So what do you want to do with them?

You will need to write a function inside a DTS Active Script transform
that returns n instances of the 8 long integer

Do you want then to take in 1 row and write many ?

Allan

"SQL_developer" <vlavanya (AT) gmail (DOT) com> wrote


Quote:
Thank you for the reply!
The source is SQL Server. The field I am trying to pull the data from
is a comments field.
Here's an example of the values in the column

1) Fri KX 3-21-98 5:48 P.M. arrival Cxled ATRI #27068935 3-17-98
2) wed.kx10/26 Netrez 95860536

Now I need to parse through these lines and return only the 8 digit
numbers in it
The result set should be

27068935
95860536


Reply With Quote
  #5  
Old   
SQL_developer
 
Posts: n/a

Default Re: Parse for a numeric string using ActiveX in DTS - 03-17-2005 , 02:03 PM



There is another column in the table for confirmation numbers. When the
user is not sure of the confirmation number, they type it in the
comments field. I need to look at the comments field, see if they have
typed in the confirmation number ( which is always 8 digits) and then
compare the string with all valid confirmation numbers in another
table. If the string matches with an existing confirmation number, I
need to update the first table with the string ( which is now a
validated confirmation number)

So in the above example if 95860536 is a valid confirmation number then
I need to update the field with that number.

Thank you for your valuable time!

Lavanya


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

Default Re: Parse for a numeric string using ActiveX in DTS - 03-17-2005 , 02:28 PM



Then you would pass the values found out to a lookup.

This would be very expensive though so I would look to do this something
like

Take the ID + number found out to a list
Check them in the lookup table and Update
Now update the main table

Something like that.

Allan


"SQL_developer" <vlavanya (AT) gmail (DOT) com> wrote


Quote:
There is another column in the table for confirmation numbers. When the
user is not sure of the confirmation number, they type it in the
comments field. I need to look at the comments field, see if they have
typed in the confirmation number ( which is always 8 digits) and then
compare the string with all valid confirmation numbers in another
table. If the string matches with an existing confirmation number, I
need to update the first table with the string ( which is now a
validated confirmation number)

So in the above example if 95860536 is a valid confirmation number then
I need to update the field with that number.

Thank you for your valuable time!

Lavanya


Reply With Quote
  #7  
Old   
SQL_developer
 
Posts: n/a

Default Re: Parse for a numeric string using ActiveX in DTS - 03-17-2005 , 02:35 PM



This is what I've done so far

Declare @tmp table
(
Booked_Comments_Txt varchar(255)
)

Insert into @tmp

select Comments_Txt from Reservation

select * FROM @tmp
where Comments_Txt LIKE ('%[0-9][0-9][0-9][0-9][0-9][0*9]%')

But it returns the entire comments field in the result set. What I need
is a way to return just those 8 digits.

It was being done manually, till now. But it's gotten to the point
where it's too big to handle. And that's why I'm trying to automate the
process.

Once I get the 8 digit number into my tmp table, I can easily compare
it and do the update process. But I can't seem to figure a way to get
the number alone......

Thanks

Lavanya


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

Default Re: Parse for a numeric string using ActiveX in DTS - 03-17-2005 , 03:04 PM



You need a recursive routine which looks into the string and outputs the
values found

This will have to be in a cursor as far as I can tell as well.


Look at the string
Find where your first [0-9] [0-9] [0-9] [0-9] [0-9] [0-9] [0-9] [0-9]
starts
Retrieve the value.
Set your string now to start at one space after the previously returned
string a repeat until you encounter your pattern no more.


This is so much more suited to the CLR and will be really easy in SQL
Server 2005


Allan






"SQL_developer" <vlavanya (AT) gmail (DOT) com> wrote


Quote:
This is what I've done so far

Declare @tmp table
(
Booked_Comments_Txt varchar(255)
)

Insert into @tmp

select Comments_Txt from Reservation

select * FROM @tmp
where Comments_Txt LIKE ('%[0-9][0-9][0-9][0-9][0-9][0-9]%')

But it returns the entire comments field in the result set. What I need
is a way to return just those 8 digits.

It was being done manually, till now. But it's gotten to the point
where it's too big to handle. And that's why I'm trying to automate the
process.

Once I get the 8 digit number into my tmp table, I can easily compare
it and do the update process. But I can't seem to figure a way to get
the number alone......

Thanks

Lavanya


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.