I am trying to alter large numbers of databases and I wanted to insert a variable into the alter database command. I keep getting errors. --- declare @dbname nvarchar(100) set @dbname = 'TestDB' alter database @dbname set offline with rollback immediate --- Server: Msg 170, Level 15, State 1, Line 3 Line 3: Incorrect syntax near '@dbname'. Server: Msg 102, Level 15, State 1, Line 3 Incorrect syntax near 'immediate'. --- When I substitute the TestDB value for @dbname, it works fine. Any help is appreciated.