Something like this?

-- - - - - - - - - 

CREATE FUNCTION InsertSpaces (@GivenString varchar(8000), @N int = 10,
@InsertChar varchar(1) = ' ')  
RETURNS varchar(8000) AS  
BEGIN 

declare @S varchar(8000), @L int, @I int

set @S = @GivenString   -- Temporary string to hold our modified string
set @L = len(@S)                -- Holds length so we don't have go call
len() a lot
set @I = @N                     -- Temp Integer
while @I < @L
        begin
                set @S = left(@S, @I) + @InsertChar + right(@S, @L - @I)
                set @L = @L + 1 -- Our temp string is increased by a
space now
                set @I = @I + @N + 1    -- Our position pointer advances
the num of chars + 1 for the space
        end
return @S
END

-- - - - - - - - - 

Then call it with something like this:

print dbo.InsertSpaces ('ThisIsATestOfTheEmergencyBroadcastSystem.',10,'
')

output:  ThisIsATes tOfTheEmer gencyBroad castSystem .

Or you can do something like:

Update MyTable Set MyField = dbo.InsertSpaces (MyField,10,' ')



-----Original Message-----
From: David Brown [mailto:[EMAIL PROTECTED] 
Sent: Friday, August 01, 2003 15:54
To: SQL
Subject: UDF insert space every 10 charaters

I would like some help on creating a udf that would insert a space every
10
charaters.  Some of our columns store long text that does not have
spaces.
One "word" could be 20 to 40 charaters long.  That does not wrap well in
html.  Any suggestions?

I could do this in cold fusion, but it would be very slow.

David


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=6
Subscription: 
http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribe&forumid=6

Signup for the Fusion Authority news alert and keep up with the latest news in 
ColdFusion and related topics. 
http://www.fusionauthority.com/signup.cfm

                        

Reply via email to