use master
Declare @CID integer = 1114
Declare @dbname varchar(50)
set @dbname = (select DatabaseName from [Clients].[dbo].[Client] where clientid = @CID)
select @dbname
alter database @dbname
set single_user with rollback immediate
drop database @dbname
delete from [Clients].[dbo].[client] where clientid = @CID
But I get errors
Msg 102, Level 15, State 1, Line 7
Incorrect syntax near '@dbname'.Msg 319, Level 15, State 1, Line 7
Incorrect syntax near the keyword 'with'. If this statement is a common table expression, an xmlnamespaces clause or a change tracking context clause, the previous statement must be terminated with a semicolon.Msg 102, Level 15, State 1, Line 7
Incorrect syntax near 'immediate'.