I have a very large string value which contains data separated by '|'
.
For example
Declare @string NVARCHAR(MAX)
Set @String = 'My Name|Address 1|Address 2|......'
In some string values I have something like
@String = My Name|Address 1 | Address 2|.......
I need to remove Spaces on either side of '|'
. If there is only one Space, I use
Set @string = Replace(@string,' |','|')
Set @string = Replace(@string,'| ','|')
What if I have more than One space and the count cannot be specific like
@String = My Name|Address 1 | Address 2|.......