📌  相关文章
📜  从字符串或句子中获取第一个和最后一个单词 - SQL 代码示例

📅  最后修改于: 2022-03-11 15:05:36.297000             🧑  作者: Mango

代码示例1
DECLARE @Sentence    VARCHAR(MAX) = 'The quick brown fox jumps over the lazy dog'

SELECT SUBSTRING(@Sentence, 1, CHARINDEX(' ', @Sentence) - 1) AS [First Word],
       REVERSE(SUBSTRING(REVERSE(@Sentence), 1,                CHARINDEX(' ', REVERSE(@Sentence)) - 1)) AS [Last Word]