May 9, 2011 at 7:39 am
Hi,
questions regarding password SQL2005 with special characters.
we work with batch MS-DOS for automatic migration and test on SQL2005.
ex : modif.cmd
when we execute CheckSQLVersion.cmd the parameters are :
CheckSQLVersion.cmd SERVER_NAME DB_NAME, USER_NAME, MOT_DE_PASSE
into the password, in sql2005 we could get special characters.
ex : p%1&2
into the batch, I execute the command :
call ISQLB %1 %2 %3 SQLSERVER_VERSION_RETRIEVE.SQL %4
@if %errorlevel% == 1 goto EXIT
when I run the batch, I got an SQL error.
- login failed.
how can I pass password with special characters ?
ISQLB contains :
sqlcmd -b -m-1 -r 0 -S %1 -d %2 -U %3 -P %7 -i %4 -o %TEMP%\ISQLB.TMP -w 360 >> %5
%1 = Server name
%2 = DATABASE name
%3 = User ID
%4 = File TO execute
%5 = Log file name
%6 = Output file name
%7 = PASSWORD
thank you in advance for your help
May 9, 2011 at 12:54 pm
I'm a little confused. How are you passing the command? Are you executing a .bat file? Are you using xp_cmdshell? Is this through SSIS or SSMS or a command prompt?
May 9, 2011 at 1:10 pm
Have you tried surrounding the parameter values with double-quotes?
There are no special teachers of virtue, because virtue is taught by the whole community.
--Plato
May 10, 2011 at 1:05 am
Hi,
here the order of execution :
1)-run file migrate_all.cmd that execute the command :
call CheckSQLVersion %1 %2 %3 %4 %5
@if %errorlevel% == 1 goto EXIT
2)-execute CheckSQLVersion.cmd that execute the command :
CALL ISQLB %1 %2 %3 SQLServer_version.sql %LOGFILE% %SQLFullVersionFile% %5
3)-execute ISQLB.BAT that execute the command :
- sqlcmd -b -m-1 -r 0 -S %1 -d %2 -U %3 -P %7 -i %4 -o %TEMP%\ISQLB.TMP -w 360 >> %5
I hope there is clear enough.
thanks in advance.
May 10, 2011 at 4:27 am
Not quite clear enough, unfortunately. How do you call the .cmd files? What program is causing them to run? SSMS query window? An SSIS package (run from BIDS or from the SSMS GUI "Run Package" interface)? A SQL Agent job?
Knowing this information will help us help you troubleshoot the error.
"login failed" sounds like a security issue, but we need to know what kind of security issue (i.e., what account is being affected).
Also, remote into your Dev box, open a command prompt, then paste in the actual commands both files are running. See if they work as expected or if they error out. Let us know the outcome.
May 10, 2011 at 6:45 am
freewarefw (5/10/2011)
Hi,here the order of execution :
1)-run file migrate_all.cmd that execute the command :
call CheckSQLVersion %1 %2 %3 %4 %5
@if %errorlevel% == 1 goto EXIT
2)-execute CheckSQLVersion.cmd that execute the command :
CALL ISQLB %1 %2 %3 SQLServer_version.sql %LOGFILE% %SQLFullVersionFile% %5
3)-execute ISQLB.BAT that execute the command :
- sqlcmd -b -m-1 -r 0 -S %1 -d %2 -U %3 -P %7 -i %4 -o %TEMP%\ISQLB.TMP -w 360 >> %5
I hope there is clear enough.
thanks in advance.
Try it this way:
CALL CheckSQLVersion "%1" "%2" "%3" "%4" "%5"
CALL ISQLB "%1" "%2" "%3" SQLServer_version.sql "%LOGFILE%" "%SQLFullVersionFile%" "%5"
sqlcmd -b -m-1 -r 0 -S "%1" -d "%2" -U "%3" -P "%7" -i "%4" -o "%TEMP%\ISQLB.TMP" -w 360 >> "%5"
** Note that all parameters were surrounded with double-quotes. Even when quoted there are still some characters you need to watch out for. Here is a good article on the topic: http://www.robvanderwoude.com/escapechars.php
You may need to double-up on your percent signs as well as escape some special characters using the caret.
There are no special teachers of virtue, because virtue is taught by the whole community.
--Plato
May 11, 2011 at 8:06 am
In your original post you wrote that you were calling CheckSQLVersion with 4 parameters, then you listed 5 in the last post. Is Parm4 in this file the password or is it Parm5. From the thread it looks like you are expecting it in Parm 5, but it seems it is in Parm4
Original Post
CheckSQLVersion.cmd SERVER_NAME, DB_NAME, USER_NAME, MOT_DE_PASSE
1)-run file migrate_all.cmd that execute the command :
call CheckSQLVersion %1 %2 %3 %4 %5
@if %errorlevel% == 1 goto EXIT
2)-execute CheckSQLVersion.cmd that execute the command :
CALL ISQLB %1 %2 %3 SQLServer_version.sql %LOGFILE% %SQLFullVersionFile% %5
3)-execute ISQLB.BAT that execute the command :
- sqlcmd -b -m-1 -r 0 -S %1 -d %2 -U %3 -P %7 -i %4 -o %TEMP%\ISQLB.TMP -w 360 >> %5
For better, quicker answers, click on the following...
http://www.sqlservercentral.com/articles/Best+Practices/61537/
For better answers on performance questions, click on the following...
http://www.sqlservercentral.com/articles/SQLServerCentral/66909/
Viewing 7 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply