gpt4 book ai didi

sql - 更改存储过程显示 `Argument data type ntext is invalid for argument 1 of left function` 错误

转载 作者:行者123 更新时间:2023-12-03 05:05:47 29 4
gpt4 key购买 nike

我有这个存储过程:

ALTER PROCEDURE [dbo].[OptimizedGetArticlePostAMP] 
(@PostID int)
--[ OptimizedGetArticlePostAMP] 678161
-- 732490
AS
BEGIN
DECLARE @SectionId int, @datediff int
DECLARE @postdate datetime

SELECT
P.PostId, P.SectionID, P.PostName,
MP.MetaTitle, P.Postdate, P.PostAuthor, P.IsApproved,
MP.Metadescription, MP.Metakeywords,
P.TotalViews, P.Subject, P.FormattedBody,
MV.Isvideo, MV.VideoCode, MV.VideoCaption,
A.DrComment, A.SpanishURL, PS.RedirectUrl,
MP.Canonical as Canonical, PS.StatusId,
dbo.[ GetCommentCountForPost](@PostId) as TotalReplies,
PRD.StoryImage, PRD.StoryContent,
MH.LastModifiedDate,
REPLACE(LEFT(P.FormattedBody, CHARINDEX('</strong>', P.FormattedBody) - 1),'<p><strong>By','') <--This Line shows **error**
FROM
csposts P
LEFT JOIN
NewsletterDetails A ON (P.Postid = A.postid)
LEFT JOIN
PostStatus PS ON (PS.postid = p.postid)
LEFT JOIN
PostMetatags MP ON (P.postid = MP.Postid)
LEFT JOIN
postVideo MV ON (P.postid = MV.Postid)
LEFT JOIN
CSPostAttachments PA ON P.PostId = PA.PostId
AND PA.contenttype LIKE 'audio/mpeg'
AND PA.FILENAME LIKE '%.mp3'
AND PA.isremote = 1
LEFT JOIN
PostRelatedData PRD ON P.PostId = PRD.PostId
LEFT JOIN
PostReferences PR on P.PostId = PR.PostId
CROSS APPLY
(SELECT TOP 1 LastModifiedDate
FROM ArticleModifiedHistory
WHERE ArticleModifiedHistory.Postid = P.postid
ORDER BY LastModifiedDate desc) MH
WHERE
P.Postid = @Postid
END

由于我使用了 LEFT 函数,因此显示以下错误:

Argument data type ntext is invalid for argument 1 of left function.

请让我知道我需要更改哪些内容才能使其运行。

最佳答案

Left 函数不接受 ntext 数据类型。就像 gofr1 所说,首先将其转换为 nvarchar 或使用接受 ntext 参数的子字符串函数。

关于sql - 更改存储过程显示 `Argument data type ntext is invalid for argument 1 of left function` 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37607605/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com