Prev: Xml shredding performance
Next: Query
From: Luciano (DOC) on 8 Mar 2010 10:09 I want to select a substring from a text this way: blablaNAME:myNameADDRESS:myAddressblabla What I want to get is all the text between "NAME:" and "ADDRESS:" I'm trying: SELECT SUBSTRING(myField, PATINDEX ('%NAME:%', testo) + 5, xxxxxx) Of course I can't know how long the substring is, so I don't know what to put over the xxxxx Anybody helps me? Thanks. Luciano
From: Plamen Ratchev on 8 Mar 2010 10:19 Here is one method: SELECT SUBSTRING(myField, PATINDEX ('%NAME:%', myField) + 5, PATINDEX ('%ADDRESS:%', myField) - PATINDEX ('%NAME:%', myField) - 5) You may consider splitting based on ":" as delimiter: http://www.sommarskog.se/arrays-in-sql.html -- Plamen Ratchev http://www.SQLStudio.com
From: Luciano (DOC) on 8 Mar 2010 10:33 "Plamen Ratchev" <Plamen(a)SQLStudio.com> ha scritto nel messaggio news:Ue6dnaBy87QEiAjWnZ2dnUVZ_ugAAAAA(a)speakeasy.net... > Here is one method: Thanks for the rapid answer! Luciano
|
Pages: 1 Prev: Xml shredding performance Next: Query |