Search code examples
sql-serversql-server-2008bcp

BCP when database name begins with a number


The name of our production database (created by a previous vendor) begins with numbers (e.g. 3717_databasename). As such, I keep getting the message "an error occurred while processing the command line" when trying to export the contents of a table. Here is my command:

bcp 3717_databasename..TableName out "C:\Temp\TableName.dat" -E -n -Slocalhost -Umyusername -Pmypassword

Solution

  • In such a scenario, the solution is to specify the database name separately with the "-d" switch, like so:

    bcp TableName out "C:\Temp\TableName.dat" -E -n -Slocalhost -d3717_databasename -Umyusername -Pmypassword