I am writing a stored procedure by framing a dynamic string :
the following query is a string stored in a variable. How will I execute this string ?
DELETE FROM PopularTrends
WHERE PopularID NOT IN
(
SELECT PopularID
FROM (SELECT *,
Row_number()
OVER(
PARTITION BY COUNTRY,HRefTopic
ORDER BY LastModifiedTime desc) AS RN
FROM populartrends )A
WHERE RN = 1
)