troubleshooting Question

SQL Server 2000 Split Process Issues

Avatar of rikleo2001
rikleo2001 asked on
Microsoft SQL Server
5 Comments1 Solution673 ViewsLast Modified:
Hello Experts
I am using Following procedure to split two strings which are contacted by (VBCRLF), I have tried using all possible options but didn't get any solution.

dECLARE @Data1 nvarchar(100)
Declare @Cnt int
DECLARE @RowData nvarchar(2000)
DECLARE @SplitOn nvarchar(5)
SET @RowData = 'meter(a) pulsesKWh(800)'
SET @SplitOn = CHAR(13) + CHAR(10)
Set @Cnt = 1

While (Charindex(@SplitOn,@RowData)>0)
Begin

Select Data1 = ltrim(rtrim(Substring(@RowData,1,Charindex(@SplitOn,@RowData)-1)))
Set @RowData = Substring(@RowData,Charindex(@SplitOn,@RowData)+1,len(@RowData))
Set @Cnt = @Cnt + 1
End

Select Data1 = ltrim(rtrim(@RowData))

GO

Here is the result what I am getting.
meter(a) pulsesKWh(800)

I need them like below, because they are concatinated with vbcrlf means (CHAR(13) AND CHAR(10))
meter(a)
pulsesKWh(800)

Any ideas to solve this?

Thanks in advance
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 5 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 5 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros