My example:
declare @sql varchar(50)
set @sql = 'select name from dbo.TABLENAMEPaJ '
declare @sql2 varchar(50)
set @sql2= 'select * from ' + @sql
The code above doesn't work...
I am a beginner in sql analysis and I feel like I have a lack of knowledge/practise however I didn't find an answer in the web.
How should I fix it to make it work?
Could you please help me out with this problem -
is it possible to select from a table named as the value in another table column?exec (@sql2)