Howdy group..I'm working on a couple of functions that format code for display in my application and i'm having a little trouble.I've found the LEN function that claims to do just what I'm looking for at the end of the functions but It doesen't seem to be acting as advertised..Here is my code..ALTER FUNCTION dbo.getOutput (@id bigint, @seperator varchar(5), @size int ) RETURNS varchar(255) AS BEGIN -------------------------------------------------------------------------------------DECLARE @retlength int, @seplength int, @state int, @output varchar(255)SELECT TOP 1 @state = autoStateID FROM tblState WHERE intVisitID = @id ORDER BY dtTime DESCIF @state > 0 BEGIN SELECT @output = @output+@seperator+RTRIM(LTRIM(m.chName)) FROM tblState s RIGHT OUTER JOIN link_StateName sd on s.autoStateID = sd.intStateID LEFT OUTER JOIN tblName m on sd.intNameID = m.autoNameNum WHERE autoStateID = @state SET @drugs = SUBSTRING(@drugs, @size, 225) END SELECT @retlength = LEN(@output)IF @retlength = 0 BEGIN SELECT @output = 'None' ENDRETURN @outputEND
I tried to include enough for you to see what i'm doing while not putting too much.the main part i don't understand is the last Select down. What do I have wrong here? TIAWill