This returns first 130 characters from a string + characters needed to finis the last word, but no more than 200 characters.You can put it to a scalar-valued function.declare @minLength int, @maxLength int, @originalText varchar(8000), @i intset @originalText = 'Original text for which you need summary.'set @minLength = 130set @maxLength = 200set @i = charindex(' ', @originalText, @minLength)select SUBSTRING(@originalText, 1, case when @i = 0 then @maxLength else @i end)-----------------http://it.expertmonster.com/