Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.databases.ms-sqlserver > #1478

Re: Extracting nth word in a string

From Erland Sommarskog <esquel@sommarskog.se>
Newsgroups comp.databases.ms-sqlserver
Subject Re: Extracting nth word in a string
Date 2013-05-11 17:27 +0200
Organization Erland Sommarskog
Message-ID <XnsA1BDB1920994Yazorman@127.0.0.1> (permalink)
References <0357973f-1b2f-4de6-bc76-3d2edd3b5411@googlegroups.com>

Show all headers | View raw


contracer (contracer11@gmail.com) writes:
> Please, can you help me how extract nth word in string ccs.errormessage ?
> 
> 
> Select n.caption, ccs.errormessage FROM APM_CurrentComponentStatus ccs 
> WITH (NOLOCK)
> INNER JOIN APM_Application a WITH (NOLOCK) ON ccs.ApplicationID = a.ID
> INNER JOIN Nodes n WITH (NOLOCK) ON a.NodeID = n.NodeID
> where ccs.ErrorMessage LIKE '%hit%'
> order by 2 asc
>  
> 
> ORACLE01 FS /apl/orawpsp hit 90% usage -> 533 MB available
>          FS /bd1/orawppdata/sys hit 90% usage -> 199 MB available


One possibility is to use a string-to-table that numbers the
elements, and then filter on row number. 
 
 (SELECT str FROM string_to_table(ccc.errormessage) WHERE row_number = @n)

I have a number of such functions in this article on my web site: 
http://www.sommarskog.se/arrays-in-sql-2005.html


-- 
Erland Sommarskog, Stockholm, esquel@sommarskog.se

Back to comp.databases.ms-sqlserver | Previous | NextPrevious in thread | Find similar


Thread

Extracting nth word in a string contracer <contracer11@gmail.com> - 2013-05-11 06:21 -0700
  Re: Extracting nth word in a string rja.carnegie@gmail.com - 2013-05-11 07:07 -0700
  Re: Extracting nth word in a string Erland Sommarskog <esquel@sommarskog.se> - 2013-05-11 17:27 +0200

csiph-web