Hello,
I am constructing a dynamic T-SQL query.
code snippet
----------------------------------------------------------
set @value_string = ' Select @temp_val = isNull( ' + @curr_char + ' , 0) from ##' +@input_table_name
EXEC(@value_string)
------------------------------------------------------------
Output T-SQL Query Which is Called by EXEC
*********************************************************
Select @temp_val = isNull( t , 0) from ##Test_word28July20075231713524
PROBLEM
*********************************************************
It is throwing an error at EXEC(@value_string)
Server: Msg 137, Level 15, State 1, Line 1
Must declare the variable '@temp_val'.
Debugging Notes
*******************************************************
1) I have ensured that @temp_val is declared as a float but it's not finding the variable I have declared in the body of the stored procedure.
2) Is the variable out of scope?
3) Can I declare named global variables .. like the global
temporary tables ## ?
I am constructing a dynamic T-SQL query.
code snippet
----------------------------------------------------------
set @value_string = ' Select @temp_val = isNull( ' + @curr_char + ' , 0) from ##' +@input_table_name
EXEC(@value_string)
------------------------------------------------------------
Output T-SQL Query Which is Called by EXEC
*********************************************************
Select @temp_val = isNull( t , 0) from ##Test_word28July20075231713524
PROBLEM
*********************************************************
It is throwing an error at EXEC(@value_string)
Server: Msg 137, Level 15, State 1, Line 1
Must declare the variable '@temp_val'.
Debugging Notes
*******************************************************
1) I have ensured that @temp_val is declared as a float but it's not finding the variable I have declared in the body of the stored procedure.
2) Is the variable out of scope?
3) Can I declare named global variables .. like the global
temporary tables ## ?