Following SQL get what I need:
SELECT TOP (50) [nodeId]
FROM [dbo].[cmsContentXml]
WHERE [xml] like '%creatorID="29"%'
AND [xml] like '%nodeType="1086"%'
ORDER BY [nodeId] DESC
I need to pass in the numbers as parameters, so I have follows:
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
which however, returns no record, any idea?