下面的 SQL 得到我需要的东西:
SELECT TOP (50) [nodeId]
FROM [dbo].[cmsContentXml]
WHERE [xml] like '%creatorID="29"%'
AND [xml] like '%nodeType="1086"%'
ORDER BY [nodeId] DESC
我需要将数字作为参数传递,所以我有以下内容:
exec sp_executesql N'SELECT TOP (@max) [nodeId] FROM [dbo].[cmsContentXml] WHERE [xml] like ''%creatorID="@creatorID"%'' AND [xml] like ''%nodeType="@nodeType"%'' ORDER BY [nodeId] DESC',N'@max int,@creatorID int,@nodeType int',@max=50,@creatorID=29,@nodeType=1086
但是,它没有返回任何记录,有什么想法吗?