开发者

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

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜