|
|
Question : SQL Server 2000 Split Process Issues
|
|
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
|
Answer : SQL Server 2000 Split Process Issues
|
|
what does this give
dECLARE @Data1 nvarchar(100) Declare @Cnt int DECLARE @RowData nvarchar(2000) DECLARE @SplitOn nvarchar(5) SET @SplitOn = CHAR(13) + CHAR(10) SET @RowData = 'meter(a)'+@spliton+'pulsesKWh(800)'
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
|
|
|
|
|