Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 SSMS QUERY CONDITIN LOGIC

Author  Topic 

kond.mohan
Posting Yak Master

213 Posts

Posted - 2012-02-18 : 02:41:11

i am executin one query in SSMS 2008 I got the out put like this way


DATE name party CRNCY AMT MODIFIELDSDATA
20110115 SDFS3 DSFD1 INR 10000 CPN|CLN|FE5|IPR
20120510 SDFS2 DSFD2 EUR 20000 CLN|CLN|FE5
20120510 SDFS6 DSFD3 USD 30000 CLN|CIN

hERE MY QEUERY IS I WANT TO SPLIT THE MODIFIEDFIEDSDATA COLUMN SPLIT IN PARTS THAT MEANS CPN IS 1 ROW
CLN IS 2 ROW
FE5 IS 3 ROW
IPR IS 4 ROW

ANY BODY KNOW THE PATH PLS EXPLAIN

sunitabeck
Master Smack Fu Yak Hacker

5155 Posts

Posted - 2012-02-18 : 08:06:59
You would need a string splitter function. Look at Jeff Moden's article here, he has one in Fig 21 of that article. Copy and install that on your server and then use it like this:

select
*,
Item
from
YourTable
cross apply (select Item from dbo.DelimitedSplit8K(MODIFIELDSDATA,'|'))s
Go to Top of Page
   

- Advertisement -