TSQL equivalent of "Eval"?
Hello all,
Does anyone know if there's a TSQL function that acts like a JavaScript eval? What I'd like to do is declare some of my SQL code as text variables and then use that code later by referencing that variable. Is there a way to do this?
TSQL equivalent of "Eval"?
I had the same problem. I found this solution:
Declare @SQL as varchar(1000);
SET @SQL = 'DECLARE Transfers_Cursor CURSOR FOR
SELECT * FROM tblTransferWorksheet WHERE Trans_ID IN (' + @Trans_IDs + ')'
EXEC (@SQL)
Fab