Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using sqlcmd

Status
Not open for further replies.

NormRumac

Programmer
Sep 4, 2003
41
0
0
CA
I am trying to execute a basic command to backup my database using the sqlcmd utility that comes with Sql Express 2005.

Unfortunately, my database name has a dash in it Database name is "SAMPLES-DATA". When I try to execute the following command, I get an error:

SQLCMD -S FILESERVER -E -Q "BACKUP DATABASE SAMPLES-DATA TO DISK =N'c:\temp\data.bak'"


I know the reason is because the database name has a dash '-' in it, but I cannot change that because it will break a lot of other scripts.

So, is there some solution to this problem?
 
O.k. I answered my own question...

Just put Square Brackets around the database name....[SAMPLES-DATA].



 
Try...

[tt][blue]
SQLCMD -S FILESERVER -E -Q "BACKUP DATABASE [!][[/!]SAMPLES-DATA[!]][/!] TO DISK =N'c:\temp\data.bak'"
[/blue][/tt]

-George

Strong and bitter words indicate a weak cause. - Fortune cookie wisdom
 
It's not fair when you don't even give us 5 minutes to answer question. [sad]

Just Kidding. [smile] It's always better when you figure things out on your own.

-George

Strong and bitter words indicate a weak cause. - Fortune cookie wisdom
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top