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?
Try amending your SQL statement so that you are building the statement by adding the parameters as you are sending them as part of the statement e.g.
'SELECT TOP ' + @max + ' [nodeId] '.....