By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,696 Members | 1,422 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,696 IT Pros & Developers. It's quick & easy.

difference between SYSTEM_USER and USER

P: n/a
Excuse me, what is the difference between user and system_user and which
function should be used in audit trail table ?
Thanks.

Jul 23 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Hi

From BOL:
"If the current user is logged in to Microsoft® SQL ServerT using Windows
Authentication, SYSTEM_USER returns the Windows 2000 or Windows NT 4.0 login
identification name, for example, DOMAIN\user_login_name. However, if the
current user is logged in to SQL Server using SQL Server Authentication,
SYSTEM_USER returns the SQL Server login identification name, for example,
sa for a user logged in as sa."

USER only works with SQL Security.
--
--------------------------------
Mike Epprecht, Microsoft SQL Server MVP
Zurich, Switzerland

IM: mi**@epprecht.net

MVP Program: http://www.microsoft.com/mvp

Blog: http://www.msmvps.com/epprecht/

"Zlatko Matić" <zl***********@sb.t-com.hr> wrote in message
news:d1**********@ls219.htnet.hr...
Excuse me, what is the difference between user and system_user and which
function should be used in audit trail table ?
Thanks.

Jul 23 '05 #2

P: n/a
I have noticed that system_user returns "sa" while user returns "dbo". What
is the difference and which to use in audit trail table?
Thanks.

"Mike Epprecht (SQL MVP)" <mi**@epprecht.net> je napisao u poruci interesnoj
grupi:42********@news.bluewin.ch...
Hi

From BOL:
"If the current user is logged in to Microsoft® SQL ServerT using Windows
Authentication, SYSTEM_USER returns the Windows 2000 or Windows NT 4.0
login
identification name, for example, DOMAIN\user_login_name. However, if the
current user is logged in to SQL Server using SQL Server Authentication,
SYSTEM_USER returns the SQL Server login identification name, for example,
sa for a user logged in as sa."

USER only works with SQL Security.
--
--------------------------------
Mike Epprecht, Microsoft SQL Server MVP
Zurich, Switzerland

IM: mi**@epprecht.net

MVP Program: http://www.microsoft.com/mvp

Blog: http://www.msmvps.com/epprecht/

"Zlatko Matić" <zl***********@sb.t-com.hr> wrote in message
news:d1**********@ls219.htnet.hr...
Excuse me, what is the difference between user and system_user and which
function should be used in audit trail table ?
Thanks.


Jul 23 '05 #3

P: n/a
Zlatko Matić (zl***********@sb.t-com.hr) writes:
Excuse me, what is the difference between user and system_user and which
function should be used in audit trail table ?


Depends on your business requirements.

SYSTEM_USER returns the server login, USER returns the database user. Often
a login maps to a database user with the same name, but at least for SQL
logins this does not have to be the case. (And I think it can happen with
Window logins as well, if you move a database from one server to
another.)

As a general answer, I would recommend SYSTEM_USER, unless there are some
special requirements that calls for something else.
--
Erland Sommarskog, SQL Server MVP, es****@sommarskog.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp
Jul 23 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.