Question : Error on DROP DATABASE @DBName

The follwing is giving me an error -
Declare @DBName as varChar(200)
Set @DBName = 'somedatabase'
IF EXISTS(SELECT name FROM sys.databases WHERE name = @DBName)
     DROP DATABASE @DBName
 GO

It does not like the line
DROP DATABASE @DBName

Answer : Error on DROP DATABASE @DBName

    EXEC('DROP DATABASE ' + @DBName)
Random Solutions  
 
programming4us programming4us