Please keep discussion on topic, i.e. related to Proxmox. This is the second time you asked for help with programming in this forum.
While executing, I receive an error on the % operator. Could you kindly assist me with writing properly?
I followed this question on how to parameterize query using like operator in SQL Server and read the article Set operators in SQL as a material source, but I couldn't get it to work flawlessly. I realize it's a redundant query, but I'm having difficulties setting it up.
Code:
SET @sql = N'DELETE TOP(1000) FROM ' + @tableName + ' WHERE ItemId
in (Select ItemId from dbo.History_Item
WHERE (
[FullyQualifiedName] LIKE ''' + @machine_DS + '.%'''
OR
[FullyQualifiedName] Like '''+ @machine_Kpi + '.%'''
)
)
AND datetime between'''+ @startDate +''' And '''+ @endDate +'''