declare @sTemp varchar(255)
set @sTemp = 'Duplicate records - see account #10092.2400 MEMORIAL PKWAY'
select charIndex('#',@sTemp)
select charIndex('.',@sTemp)
select substring
(
@sTemp
, charIndex('#',@sTemp) + 1
, charIndex('.',@sTemp) - charIndex('#',@sTemp) -1
)
>From: "Dylan Jones "
><mssqldba-ezmlmshield-x55075185.[Email address protected]
>To: "LazyDBA Discussion" <[Email address protected]
>Subject: Working With Strings
>Date: Thu, 24 Feb 2005 14:54:18 -0800
>
>Hi folks,
>
>I am trying to pull out a string from within a string. For example
>within the following string 'Duplicate records - see account #10092.2400
>MEMORIAL PKWAY' I want to pull out the ID that follows the # and ends
>with the decimal "." . Using VB this is a fairly straightforward
>exercise. BOL string functions do not offer what I need to pull this
>off. Any ideas?
>
>
>Dylan A Jones
>SQL DBA
>SurfControl Inc (Scotts Valley)
>w: 831 440 2568
>m:831 566 3089
>
>
>Get the latest news on SurfControl and our products,
>subscribe to our monthly e-newsletter, SurfAdvisory at:
>http://www.surfcontrol.com/resources/surfadvisory/surfadvisory_signup.aspx
>
>*********************************************************************
>The information in this email is confidential and may be legally
>privileged. It is intended solely for the addressee. Access to this
>email by anyone else is unauthorized. If you are not the intended
>recipient, any disclosure, copying, distribution or any action taken
>or omitted to be taken in reliance on it, is prohibited and may be
>unlawful. If you believe that you have received this email in error,
>please contact the sender.
>*********************************************************************
>SurfControl Inc.
>5550 Scotts Valley Drive
>Scotts Valley, California 95066
>831-440-2500
>
>
>
>---------------------------------------------------------------------
>TO REPLY TO EVERBODY , PLEASE CLICK REPLY-ALL, NOT JUST REPLY
>Website : http://www.LazyDBA.com
>To unsubscribe: http://www.lazydba.com/unsubscribe.html
>For additional commands, e-mail: mssqldba-[Email address protected]
>
MS Sql Server LazyDBA home page