I need to update a table from another table several times in succession. In order to make this script easier for people to use, I'd like to be able to dynamically reference it. Something like this:
declare @databasename sysname
set @databasename = 'm2mdata01.dbo'
select * from @databasename.mytable
This isn't working. Any suggestions as to how I can accomplish this?