I would like to have the list of nodes set at the top of the script, then check if they are in the table. The following code does not throw errors, but the logic is not working. It does not print the message when one of the nodes in the list exists.
DECLARE @nodeId nvarchar(50)
SET @nodeId = 'SomeNodeID, SomeOtherNodeID'
IF EXISTS (SELECT NodeId FROM dbo.tblNodeMaster WHERE NodeId in (@nodeId))
BEGIN
PRINT RTRIM(CONVERT(varchar(30), GETDATE())) + ' node exists.'
RETURN
END
Using the following code without a variable it works fine. It will print the message when any node in the list exists.
IF EXISTS (SELECT NodeId FROM dbo.tblNodeMaster WHERE NodeId in ('SomeNodeID', 'SomeOtherNodeID'))
BEGIN
PRINT RTRIM(CONVERT(varchar(30), GETDATE())) + ' node exists.'
RETURN
END
inin that way with a string - it's asetoperation, it doesn't parse the string.