Which user account is running SQLCMD in T-SQL Script without -U and -P option?

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-08 06:38:20

问题


I am using sqlcmd in a T-SQl script to write a text file to a network location. However SQLCMD is failing to write to that location due to access permission to the network folder. SP is being run under my user account which has access to the network folder.

Could you please help me under which account sqlcmd will run if I do not specify -U and -P option in TSQL Script?


回答1:


Use this to find the user name:

PRINT Suser_Sname();



回答2:


If you don't provide credentials with -u/-p it will try to use windows authentication; i.e the windows account of whomever is running it.

I often just use Process Monitor to look at what account is being used and what the permission error is.




回答3:


You say you are using SQLCMD in a T-SQL script, don't you mean you are using SQLCMD to run a T-SQL script? How is your script writing a text file? Does it work in SQL Manager? My guess is that the user account SQL Server is running under doesn't have access to that location.



来源:https://stackoverflow.com/questions/2476508/which-user-account-is-running-sqlcmd-in-t-sql-script-without-u-and-p-option

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!