At first line of query its written as Use Master, so all statement stating SELECT db_name() gives master, execute statement will not make any effect here.....
_______________________________________________________________
To get quick answer follow this link:
http://www.sqlservercentral.com/articles/Best+Practices/61537/