I'm trying to run this code:
**I get this output**
Here, literals @cstring and @rstring do not have their values at output. Please help. Thanks.
As @Oleg has already pointed out, it is working as it should be. sp_ExecuteSQL would assign the values to the params at runtime while execution. But it would not change the content of your dynamic SQL variable @SQL. So if you are printing your dynamic SQL after/before execution, it will still print it the same. If you want to see the values printed as well then you need to tweak your dynamic sql something like
answered Jun 14, 2012 at 07:37 AM