September 17, 2007 at 9:07 am
good morning,
I have written a sql script to build some bcp out statements in a file to be run as a batch. In this script, I have coded in the password (I know - not good practice, but its a test system). Everything looks good with the batch file the script creates. However, when I run the batch file, I am prompted for a password, even though it is in the script. When I run the command exactly as it appears in the batch file, it runs without prompting for a password.
Environment is SQL 2000 SP3 and bcp 8.00.832
anyone have any idea on how to prevent the prompts? I have over 800 tables to bcp out and can't really type in the password 800+ times.
thanks....
Peter
September 17, 2007 at 5:30 pm
It would be good if you posted one of the offending lines of code (sans password)... there's lot's of options in BCP...
--Jeff Moden
Change is inevitable... Change for the better is not.
September 19, 2007 at 8:27 pm
have you tried what happens if you don't type in the password. This is a hit and try method. The other thing could be that it is not recognizing that you have enterd a password - so check there is no space between them.
I remember writing bcp commands without problem. we even used the environment variables to save passwords.
btw, just wondering, is using the environment variables to save passwords a good practice?
September 19, 2007 at 9:17 pm
Or, the OP could post the offending code, sans password, so we can actually try to troubleshoot the command for him
--Jeff Moden
Change is inevitable... Change for the better is not.
September 20, 2007 at 7:16 am
I figured it out. For a field terminator I was using a pipe, but I was using the notation we use when doing it in Unix. It looked like this:
-t\|
when it should have looked like this:
-t"|"
once I made the change, I was no longer prompted and bcp used the password I provided. I don't know exactly why \| didn't work, so if anyone can explain that, great.
September 20, 2007 at 8:06 am
Because the "pipe" character is not one of those "special" characters... \t doesn't mean "use [t] as the delimiter", for example... it means "use a tab as the delimiter". the [|] character is not on the reserved list of characters so it must be a literal in the command...
... and thanks for the feedback. Most folks just go on their merry way when they figure something out for themselves...
--Jeff Moden
Change is inevitable... Change for the better is not.
September 21, 2007 at 4:53 am
Peter, haveyou tried the -T option to connect with your windows id, then you will not need to enter your password.
george
---------------------------------------------------------------------
September 21, 2007 at 8:25 pm
Great idea, George... just keep in mind that only works if you're calling BCP via xp_CmdShell in T-SQL or you have Windows Authentication enabled on the server...
--Jeff Moden
Change is inevitable... Change for the better is not.
September 23, 2007 at 11:44 pm
Jeff Moden (21/09/2007)
Great idea, George... just keep in mind that only works if you're calling BCP via xp_CmdShell in T-SQL or you have Windows Authentication enabled on the server...
... and you don't use "Local System account" to start SQL Server. :hehe:
_____________
Code for TallyGenerator
September 24, 2007 at 7:19 am
george sibbald (9/21/2007)
Peter, haveyou tried the -T option to connect with your windows id, then you will not need to enter your password.
george
I did try that but it was still failing because of the \|. Once I resolved that, both -T and -U, -P worked fine.
Viewing 10 posts - 1 through 9 (of 9 total)
You must be logged in to reply to this topic. Login to reply