开发者

how do i check under which username a script is run?

i have this script:

BACKUP DATABASE timeclockplus TO DISK = 'C:\Program Files\Microsoft SQL Server\MSSQL.2\MSSQL\Backup\backup.bak'

how do i know which username is 开发者_如何学Pythonexecuting it? the reason i ask is because i want to grant extra privelages to the current username so that instead of writing that backup folder i can write to a different folder


There is no context as such except for sa inside the DB engine.

Based on your recent questions, you mean external SQL Server context which will be the service account used (you can see it in Services.msc). So if you are using domain\Specialuser then you could permission domain\Specialuser on a folder.

However, SQL Server 2005 introduced some groups that should contain the service account specified at install time and these should be used for external (eg outside SQL Server) permissions

Some details in KB 283811 , but best seeing "Reviewing Windows NT Rights and Privileges Granted for SQL Server Service Accounts". The groups mentioned here are what you should permission on your desired folder.


Take a look at SUSER_SNAME().

(That page is a bit misleading, passing no param returns the current user - either an SQL Logon or a domain\user depending on the auth mode)

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜