Use a variable in an ALTER DATABASE command

Note:  Best viewed in Internet Explorer 6 and above

Implementation: How to use a variable in an ALTER database command.

Scenario: Lets say,you want to use a variable in an ALTER DATABASE for putting all or selected DBs offline/online/attach/detach purpose.

Infrastructure:The below query/procedure has been run/tested successfully on sql server 2005,2008,2008 R2 and 2012.

Kindly find the below link for the same.

https://app.box.com/s/dtp8qdc582o44tpo9u7b8p9g0k7np7fh