I have to create a query which should create a database by concatenating the machine name and any given name. I have following SQL query but I am getting an error. Please suggest me.
DECLARE @machinename VARCHAR(100)
SET @machinename=HOST_NAME()
CREATE DATABASE @machinename+' Test'
You need to use Dynamic SQL and you need to remove the space in the
' Test'portion:From MSDN Database identifiers: