Programming, SQL Database

Split Comma Separated List Without Using a Function

recherche femme de mГ©nage 37 There is lots way to get the table from comma separate data by using the function to return table but I found the other way using XML path and using this you get better performance than another way while there are lots of data in a table. Even you get more time using function while to join with other tables so you can consider following example and fit your need and definitely you would get better performance and could enhance your query.

http://secfloripa.org.br/esminer/6409 binär optionen handeln wikipedia Example:
http://shortcreek.us/?enfiors=write-a-successful-online-dating-profile&77f=6b Table: ProductGroup

binäre optionen steuerrecht SELECT GroupID,ProductCode FROM ProductGroup

application iphone rencontres gay GroupID     ProductCode
——————————————————-
1                 GH0001,MH0001,GH0002
2                 GH0003,MH067
3                 GH0004,MH0002,MH0670

enter site Now we can get result by run following query to get each ProductCode separately with GroupID as below:

Come e click here Senza Rischiare a Ottobre 2017. Sapere come e dove investire i propri soldi in modo sicuro e redditizio sembra una questione molto SELECT GroupID, LTRIM(RTRIM(m.n.value('.[1]','varchar(8000)'))) AS Code FROM ( SELECT GroupID,CAST('' + REPLACE(Code,',','') + '' AS XML) AS x FROM @t )t CROSS APPLY x.nodes('/XMLRoot/RowData')m(n)

see Result that you want as below:

http://blossomjar.com/pacinity/710 GroupID     Code
———————————-
1               GH0001
1               MH0001
1               GH0002
2               GH0003
2               MH067
3               GH0004
3               MH0002
3               MH0670

So finally the result with separate ProductCode with associated GroupID and now you can use this trick to join with other table to compare record by each ProductCode.

Tagged

Leave a Reply

Your email address will not be published. Required fields are marked *