Showing posts with label numeric. Show all posts
Showing posts with label numeric. Show all posts

Wednesday, March 28, 2012

Parse

I have one database backup file that is created daily with directory
structure listed
below what is the easy way to parse or extract that numeric value from the
command listed below?
Thank You,
EXEC xp_cmdshell 'dir \\DALL3\T$\dump\DALLAS\*.BAK'Joe,
Assuming the command is stored in a column (Col1) in a table (TEST1) and is
a single value, the following should work:
SELECT SUBSTRING(Col1,(CHARINDEX('',Col1,CHARI
NDEX('',Col1,1)+ 2)-1),1)
FROM TEST1
HTH
Jerry
"Joe K." <Joe K.@.discussions.microsoft.com> wrote in message
news:7771B914-DFFF-473C-881A-82552D7FEF45@.microsoft.com...
> I have one database backup file that is created daily with directory
> structure listed
> below what is the easy way to parse or extract that numeric value from the
> command listed below?
> Thank You,
> EXEC xp_cmdshell 'dir \\DALL3\T$\dump\DALLAS\*.BAK'|||Please, be more specific. At least give a few typical samples, and specify
what exactly you'd like to parse - is it the whole command, the parameter,..
.
what?
ML

Wednesday, March 21, 2012

Parse a numeric string from a field

Hello All,

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
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

This is what I've done so far

Declare @.tmp table
(
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.

Any Ideas??

Thanks in advance!!!You could use the following:

select substring(comments_txt,
patindex('%[0-9][0-9][0-9][0-9][0-9][0***9]%', comments_txt), 8)
from @.tmp where Comments_Txt
like ('%[0-9][0-9][0-9][0-9][0-9][0***9]%')

--
David Rowland
dbmonitor.tripod.com|||Thank You very much !!! That was just what I needed.