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

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!eternal-september.org!feeder.eternal-september.org!mx05.eternal-september.org!.POSTED!not-for-mail
From Erland Sommarskog <esquel@sommarskog.se>
Newsgroups comp.databases.ms-sqlserver
Subject Re: Extracting nth word in a string
Date Sat, 11 May 2013 17:27:21 +0200
Organization Erland Sommarskog
Lines 27
Message-ID <XnsA1BDB1920994Yazorman@127.0.0.1> (permalink)
References <0357973f-1b2f-4de6-bc76-3d2edd3b5411@googlegroups.com>
Mime-Version 1.0
Content-Type text/plain; charset=windows-1252
Content-Transfer-Encoding 8bit
Injection-Info mx05.eternal-september.org; posting-host="78e2ae7e6764121e217a035f19bdb315"; logging-data="18711"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+v6sw6esVHvA4MDnh8jtYE"
User-Agent Xnews/2006.08.24 Mime-proxy/2.1.c.0 (Win32)
Cancel-Lock sha1:/za8hSBL9YdrMBVCZftm6Ntliy8=
Xref csiph.com comp.databases.ms-sqlserver:1478

Show key headers only | 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 | Unroll thread


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