Solved

Special character in MSSQL database name

Posted on 2013-11-14
1
444 Views
Last Modified: 2013-11-14
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
Comment
Question by:Trouble01
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 12

Accepted Solution

by:
Tony303 earned 500 total points
ID: 39647384
Put the DB name in square brackets?

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

Featured Post

How Do You Stack Up Against Your Peers?

With today’s modern enterprise so dependent on digital infrastructures, the impact of major incidents has increased dramatically. Grab the report now to gain insight into how your organization ranks against your peers and learn best-in-class strategies to resolve incidents.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Developing a front end to SPLUNK 1 64
point in time restore in SQL server 26 46
disk usage reporting tools 27 56
Why is this SQL bringing back extra rows? (parsing XML data) 4 39
Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question