I want to use a variable I pass to a stored procedure to be used as table name in my query to be used in cursor to be used to send email. My snippet sample is below:
--DECLARE @getemail CURSOR
--SET @getemail = CURSOR FOR
DECLARE @getemail CURSOR FOR
SET @recipientquery = 'SELECT * FROM '+@tableA+''
EXEC sys.sp_executesql @recipientquery
Questions is why I am getting error in the for part saying:
Incorrect syntax
What is the correct syntax to use when using a string query after for in cursor?