开发者

Running a T-SQL script under different credentials using SQLCMD.exe utility

开发者 https://www.devze.com 2023-03-04 10:57 出处:网络
I created a batch file and placed the following line into it: runas /user:internal\\c39293 \"C:\\Program Files\\Microsoft SQL Server\\100\\Tools\\Binn\\SQLCMD.EXE\" -E -S WLDZ9454 -d ChadDb -Q \"usp_

I created a batch file and placed the following line into it:

runas /user:internal\c39293 "C:\Program Files\Microsoft SQL Server\100\Tools\Binn\SQLCMD.EXE" -E -S WLDZ9454 -d ChadDb -Q "usp_Test"  

I was trying to run the stored procedure usp_Test on the server WLDZ9454 against the ChadDb database.

When I execute it, I just get info regarding param options, no error mesage, so it isn't clear to me what I am doing wrong.

Note that when I run the code minus the code that attempts to run under different credentials, it works:

"C:\Program Files\Microsoft SQL Server开发者_C百科\100\Tools\Binn\SQLCMD.EXE" -E -S WLDZ9454 -d ChadDb -Q "usp_Test" 


I suspect it's because you have not enclosed the program you are running and its parameters in quotes.

SqlCmd is therefore executed without any parameters.

 runas /user:internal\c39293 """C:\Program Files\Microsoft SQL Server\100\Tools\Binn\SQLCMD.EXE"" -E -S WLDZ9454 -d ChadDb -Q ""usp_Test"""
0

精彩评论

暂无评论...
验证码 换一张
取 消