Unanswered: Issues with exporting/importing database with bcp & brackets in db name
I have created and application which exports given database to txt-files and imports them to a new database on given server. The basic procedures goes very well. A small error prevails, which I am unable to figure out:
There seems to be a problem with brackets: '(' and ')' in the database name with bcp. It seems that I am unable to export or import database, when I have those characters in the database name. (I have made the implementation so that the user does not need a give a name for a new database. If a database with a same name already exists in the given server, the database name is transformed to "mydbname(2)" or "mydbname(3)" etc.
With SQL, creating a database, with brackets in it's name, requires that square brackets must be used: CREATE DATABASE [sourcedbname(2)]. However, With the bcp, I have not yet found a markup by which the bcp would accept this kind of an syntax.
bcp mydb(2).dbo.BinaryDefaultValues out C:\table1.txt -c -T -S mycomputer\myserver returns "Incorrect syntax near '.'.
bcp [mydb(2)].dbo.BinaryDefaultValues out C:\table1.txt -c -T -S mycomputer\myserver returns "Return login fails."
So, how should I solve this issue?
all the the help is highly appreciated,
Addition: Forgot to mention that I am using Sql Server 2000 MSDE and Visual Studio .NET 2003 on Windows 2000 as my development environment.