title: How to use a variable for the database name in T-SQL?
body: <p>I use the database name in several places in my script, and I want to be able to quickly change it, so I'm looking for something like this:</p>
  
  <pre><code>DECLARE @DBNAME VARCHAR(50)
  SET @DBNAME = 'TEST'
  
  CREATE DATABASE @DBNAME
  GO
  ALTER DATABASE @DBNAME SET COMPATIBILITY_LEVEL = 90
  GO
  ALTER DATABASE @DBNAME SET RECOVERY SIMPLE 
  GO
  </code></pre>
  
  <p>But it doesn't work. So what's the correct way to write this code?</p>