Solved

Special character in MSSQL database name

Posted on 2013-11-14
1
433 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
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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Suggested Solutions

Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.
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…

744 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now