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)
 Need this Oracle logic converted to SQL Server

Author  Topic 

raghvendra deshpande
Starting Member

1 Post

Posted - 2012-09-03 : 05:18:00
Hi all,
I have written following query in Oracle.
Here is the code:
Code:
(SELECT replace(REGEXP_SUBSTR (domainList001, '[^,]+', 1, LEVEL),'''','' ) FROM DUAL CONNECT BY REGEXP_SUBSTR (domainList001, '[^,]+', 1, LEVEL) IS NOT NULL)


Here domainList001 is a string like 'domain1,domain2,domain3,domain4'
and the above code breaks individual elements and I get following output:
domain1
domain2
domain3
domain4
i.e one row for each element.

Now I have to port it to SQL Server and DB2 syntax.

Any help is appreciated.


Thanks,
Raghvendra

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2012-09-03 : 05:26:44
use one of the following
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=25830&SearchTerms=CSVTable
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=76033


select *
from dbo.CSVTable('domain1,domain2,domain3,domain4')

or

select *
from dbo.fnParseList(',', 'domain1,domain2,domain3,domain4')


that is for SQL Server. I have no idea on DB2


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page
   

- Advertisement -