Thread: Help with BCP
11-10-04, 10:07 #1Registered User
- Join Date
- Nov 2004
Unanswered: Help with BCP
NOTE: Addresses, usernames, and passwords have been changed.
I am trying to do a Batch Backup of my SQL Server (sql6.alpha.net) to (sql4.alpha.net). So I go onto sql6, get to a dos prompt and type the following (in order to backup the first table, "Accounts").
BCP "AlphaOffice.sa.Accounts" out "AOBackup-Tuesday.Accounts" -S"sql4.alpha.net,10775" -U"username" -P"password"
I get the following Error:
SQLState = 37000, NativeError = 4060
Error = [Microsoft][ODBC SQL Server Driver][SQL Server]Cannot open database requested in login 'AlphaOffice'. Login fails.
Now - I Know for a fact that the database "AlphaOffice" exists. My question is: the -P and -U parameters are for a username and password. Is this the username/password for the source DB (housed on the computer I am running BCP from), or the username/password for the destination server (Where the backup will eventually be housed)? If I use the User/Pass from the source, I get the above message. If I used the User/Pass of the destination, I get an error which states Access is Denied. Any thought?
11-10-04, 12:46 #2Registered User
- Join Date
- Feb 2002
- Houston, TX
The -U -P refers to the server you are exporting data from or importing data to. In the example you have listed the -U -P is for sql4.alpha.net. When you bcp data to sql6.alpha.net you will use a uid/pwd for that box. You might also want to through a "-n" to extract the data in native mode.
Having said all that, DTS would be an easier way to go. You could DTS the data out of sql4 and then DTS the data into sql6 or go directly from sql4 to sql6.
btw, the error message you are getting suggests that the DB you are referencing does not exsist rather than a login problem.
Last edited by Paul Young; 11-10-04 at 16:48.Paul Young
(Knowledge is power! Get some!)
11-10-04, 19:35 #3Registered User
- Join Date
- Jul 2003
- San Antonio, TX
Personally I'd still prefer BCP over DTS (unless it's a Yukon DTS) simply because you can touch and feel the resulting file before you can send it to the destination. The trick there is to know whether the table contains an IDENTITY field on the destination, and if you need to retain the values from the source,- specify -E switch. And you definitely need to include either "-n" or "-c" switch, otherwise the utility would take you through a series of "employment application" type questions and offer to save the answers in a format file before you get to see the actual extraction process."The data in a record depends on the Key to the record, the Whole Key, and
nothing but the Key, so help me Codd."