I\'ve got a stored procedure that allows an IN parameter specify what database to use. I then use a pre-decided table in that database for a query. The problem I\'m having i
try the sp_executesql built in function. You can basically build up your SQL string in your proc, then call
exec sp_executesql @SQLString. DECLARE @SQLString nvarchar(max) SELECT @SQLString = ' SELECT * FROM ' + @TableName EXEC sp_executesql @SQLString