If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > Microsoft SQL Server > BCP Password Issue

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 01-12-12, 05:12
buzmay buzmay is offline
Registered User
 
Join Date: Jan 2012
Posts: 44
BCP Password Issue

Hi guys,

I desperately need help with my BCP script everything works good so far I do not add in the script my password as -P actualpassword

However I would like to know how to do this in the script since I need to import plenty of files into mysql server.
The script I have looks like this

@echo off
bcp TestDB3.dbo.xxx_data in "Z:\path\data\XXX.txt" -F 2 -S servername -U MY_USER_NAME -f "Z:\path\data\format-data.fmt"
pause

the above script works fine but, asks me all the time to prompt my password. However if if I try to add the password as in the following scrip it will complain that the login has failed:


@echo off
bcp TestDB3.dbo.xxx_data in "Z:\path\data\XXX.txt" -F 2 -S servername -U MY_USER_NAME -P xxxxxxx -f "Z:\path\data\format-data.fmt"
pause


Any ideas how to fix this? Thanks in advance.
Reply With Quote
  #2 (permalink)  
Old 01-12-12, 05:25
gvee gvee is offline
www.gvee.co.uk
 
Join Date: Jan 2007
Location: UK
Posts: 10,156
SQL login or Windows authentication?
__________________
George
Twitter | Blog
Reply With Quote
  #3 (permalink)  
Old 01-12-12, 05:27
buzmay buzmay is offline
Registered User
 
Join Date: Jan 2012
Posts: 44
sql server authentication
Reply With Quote
  #4 (permalink)  
Old 01-12-12, 06:35
gvee gvee is offline
www.gvee.co.uk
 
Join Date: Jan 2007
Location: UK
Posts: 10,156
I wouldn't have thought having a command file with both the username and password to an SQL account that has permissions to modify data is a good idea. Have you considered using windows auth (-T)? Remember that if you have this script set up to run in a job then it runs using the credentials of the account that SQL Server Agent uses.

If you insist on using SQL auth then have you confirmed your ability to connect directly to the SQL instance (using SSMS for instance) using the details in your script? If you can then check the accounts ability to modify data.

It will also be useful if you post the actual error message in full.
__________________
George
Twitter | Blog
Reply With Quote
  #5 (permalink)  
Old 01-12-12, 06:49
buzmay buzmay is offline
Registered User
 
Join Date: Jan 2012
Posts: 44
Thanks for the answer, I have considered to use windows auth, but I would like to know why there is a -P option if it does not work?

This is the error I get:

SQLSTATE = 28000, NativeError = 18456
Error = [Microsoft] [SQL Server Native Client 10.0] [SQL Server]Login failed for user 'myname'
Reply With Quote
  #6 (permalink)  
Old 01-12-12, 08:41
gvee gvee is offline
www.gvee.co.uk
 
Join Date: Jan 2007
Location: UK
Posts: 10,156
The -P option does work

So the login is failing. Check that you can connect to the instance using SSMS with these SQL login details (change the drop down from Windows Auth to SQL Auth when connecting). Then check that this account can access the database in question.
__________________
George
Twitter | Blog
Reply With Quote
  #7 (permalink)  
Old 01-12-12, 09:26
MCrowley MCrowley is offline
Wage drone 24601
 
Join Date: Jan 2003
Location: Massachusetts
Posts: 4,899
Do you have any special characters in the password that may need to be escaped?
Reply With Quote
  #8 (permalink)  
Old 01-12-12, 09:30
Pat Phelan Pat Phelan is offline
Resident Curmudgeon
 
Join Date: Feb 2004
Location: In front of the computer
Posts: 12,609
My first guess is that there is a Windows "special character" inside the password.

Purely for testing purposes to see if I'm correct, create a second SQL Authenticated user with only letters and numbers in both the user name and the password (no special characters at all). Modify your script to use this username and password.

If the modified script will run using the sanitized username and password, then we need to explore which characters you are using and how you need to work around the problem. You can find details at remarks if this is the case.

-PatP
__________________
In theory, theory and practice are identical. In practice, theory and practice are unrelated.

Last edited by Pat Phelan; 01-12-12 at 09:35.
Reply With Quote
  #9 (permalink)  
Old 01-12-12, 11:12
Brett Kaiser Brett Kaiser is offline
Window Washer
 
Join Date: Nov 2002
Location: Jersey
Posts: 10,303
Is the password password?
__________________
Brett
8-)

It's a Great Day for America everybody!

dbforums Yak CorralRadio 'Rita
dbForums Member List
I'm Good Once as I ever was

The physical order of data in a database has no meaning.
Reply With Quote
  #10 (permalink)  
Old 01-16-12, 10:25
buzmay buzmay is offline
Registered User
 
Join Date: Jan 2012
Posts: 44
Sorry for the late answer, and thanks for the help guys. The password is exactly the same password, since it is a script I am able to see with letters the password, so I am 100% sure I am not missing something, also there are no slashes on it that might make believe the password has some special characters.

I think the easier thing will be to get a windows authentication, rather than sql.

Thanks a lot!
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On