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

半城伤御伤魂 提交于 2019-12-07 08:20:31
Rashini Nanayakkara

Use this to find the user name:

PRINT Suser_Sname();

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.

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.

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