I’m trying to figure out a select statement that will truncate a field value to 100 characters and add … to the end of it so like:
HundredLetterSentence becomes HundredLetter Sen… or something like that. Here is the select statement from my stored procedure. I’m kinda stuck from here. The Select TOP(1) Description is where I want to do the truncation.
SELECT [TI].[TicketID]
, CAST([TI].[Subject] AS VARCHAR(100)) [Subject]
, [TA].[DueDate]
, CAST(
( SELECT
TOP(1) SUBSTRING(Description, 0, 100)
FROM Comment
WHERE TicketID = [TI].[TicketID]
ORDER BY CommentDate DESC
) AS VARCHAR(100)
) AS [Description]
FROM [dbo].[Ticket] [TI]
INNER JOIN [dbo].[Task] [TA]
ON [TI].[TicketID] = [TA].[TicketID]
INNER JOIN [dbo].[Task_Status] [TS]
ON [TA].[StatusID] = [TS].[StatusID]
WHERE [TI].[IsDeleted] = 0
AND [TS].[IsDeleted] = 0
AND [TS].[Status] = 'Open'
AND [TI].[AssigneeView] IS NULL
AND [TI].[AssignedTo] = @AssignedTo
What will work is something like –