Solved

Special character in MSSQL database name

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

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

840 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