我正在尝试找出一个 select 语句,它将字段值截断为 100 个字符并将 ... 添加到它的末尾,如下所示:
HundredLetterSentence 变成 HundredLetter Sen... 或类似的东西。这是我的存储过程中的 select 语句。我从这里有点卡住了。Select TOP(1) Description 是我想要截断的地方。
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