I'd be looking at the "STUFF" command here.
If you can't be sure of how long the string is, it may be easier to loop for the length of the string - perhaps make it a function to call?
example:
Code:
DECLARE @string as varchar(max), @loop as int
SET @string = '1234567890123456789'
SET @loop = LEN(@string)/5
WHILE @loop > 0
BEGIN
SET @string = STUFF(@string,1+(@loop*5),0,'-')
SET @loop = @loop-1
END
SELECT @string
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.