I have a simple requirement where I need to replace a variable with the database name coming from another table.
I have a table called config setting
Key value
ClubcardDB ClubardDetailsDB
Code
Declare @Value varchar(100)
select @Value= value configsetting where Code=’ ClubcardDB’
Select top 10 * from [@Value].[dbo].[ClubcardDetails]
it is giving an error: Invalid object name '@Value.dbo.ClubcardDetails'.
I do not want to build and dynamic query..