D J Horton Consulting Ltd

Personal reference to useful tips and tricks for SQL Server, SQL Server Reporting Services and Crystal Reports.



My alternative to scraps of paper lying about.



Others may find bits of it useful!








Thursday, 22 October 2009

Condensing large character string and removing carriage returns - SSRS

***Update ***
Function created:

for condensing a large character string and removing any carriage returns (such as in a comments field).

Function shortcomment(byval commentstring as string, stringlength as integer) as string

if commentstring="" or isnothing(commentstring)
return commentstring
else

commentstring=replace(commentstring, chr(10)," ")
if commentstring.length >stringlengthcommentstring=left(commentstring, stringlength) & "....."
return commentstring
else
return commentstring
end if
end if
end function


to implement:

=code.shortcomment(Fields!comments.Value, 10)

where 10 is the condensed length

No comments: