Special character in MSSQL database name

Hi, I have a program that transfers data from certain tables in one database to identical tables in another database using the following query :
insert into destinationdb.dbo.table1
select * from sourcedb.dbo.table1

However a customer has a database called A&E and the statement fails due to the "&" character. Is there a way to modify the sql to overcome this?

Thanks in advance.
Trouble01Asked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
Tony303Connect With a Mentor Commented:
Put the DB name in square brackets?

SELECT *
FROM [A&E].dbo.table1
0
All Courses

From novice to tech pro — start learning today.