Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 462
  • Last Modified:

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.
0
Trouble01
Asked:
Trouble01
1 Solution
 
Tony303Commented:
Put the DB name in square brackets?

SELECT *
FROM [A&E].dbo.table1
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

What Kind of Coding Program is Right for You?

There are many ways to learn to code these days. From coding bootcamps like Flatiron School to online courses to totally free beginner resources. The best way to learn to code depends on many factors, but the most important one is you. See what course is best for you.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now