返回User Name的函数收集

1,suser_sname

Returns the login name associated with a security identification number (SID).

Syntax

SUSER_SNAME ( [ server_user_sid ] )

Arguments

server_user_sid

Is the optional login security identification number. server_user_sid is varbinary(85). server_user_sid can be the security identification number of any SQL Server login or Microsoft Windows user or group. If server_user_sid is not specified, information about the current user is returned. If the parameter contains the word NULL will return NULL.

SUSER_SNAME can be used as a DEFAULT constraint in either ALTER TABLE or CREATE TABLE. SUSER_SNAME can be used in a select list, in a WHERE clause, and anywhere an expression is allowed. SUSER_SNAME must always be followed by parentheses, even if no parameter is specified.

When called without an argument, SUSER_SNAME returns the name of the current security context. When called without an argument within a batch that has switched context by using EXECUTE AS, SUSER_SNAME returns the name of the impersonated context. When called from an impersonated context, ORIGINAL_LOGIN returns the name of the original context.

2,suser_name

Returns the login identification name of the user.

Syntax

SUSER_NAME ( [ server_user_id ] ) 

Arguments

server_user_id

Is the login identification number of the user. server_user_id, which is optional, is int. server_user_id can be the login identification number of any SQL Server login or Microsoft Windows user or group that has permission to connect to an instance of SQL Server. If server_user_id is not specified, the login identification name for the current user is returned. If the parameter contains the word NULL will return NULL.

In SQL Server version 7.0, the security identification number (SID) replaced the server user identification number (SUID).

SUSER_NAME returns a login name only for a login that has an entry in the syslogins system table.

SUSER_NAME can be used in a select list, in a WHERE clause, and anywhere an expression is allowed, and must always be followed by parentheses, even if no parameter is specified.

3,USER_NAME

Returns a database user name from a specified identification number.

Syntax

USER_NAME ( [ id ] )

Arguments

id

Is the identification number associated with a database user. id is int. The parentheses are required.

Remarks

When id is omitted, the current user in the current context is assumed. If the parameter contains the word NULL will return NULL.When USER_NAME is called without specifying an id after an EXECUTE AS statement, USER_NAME returns the name of the impersonated user. If a Windows principal accesses the database by way of membership in a group, USER_NAME returns the name of the Windows principal instead of the group.

4,USER

Allows a system-supplied value for the database user name of the current user to be inserted into a table when no default value is specified.

Syntax

USER

Remarks

USER provides the same functionality as the USER_NAME system function.

Use USER with DEFAULT constraints in either the CREATE TABLE or ALTER TABLE statements, or use as any standard function.

USER always returns the name of the current context. When called after an EXECUTE AS statement, USER returns the name of the impersonated context.

If a Windows principal accesses the database by way of membership in a group, USER returns the name of the Windows principal instead of the name of the group.

5,SYSTEM_USER

Allows a system-supplied value for the current login to be inserted into a table when no default value is specified.

Syntax

SYSTEM_USER

Remarks

You can use the SYSTEM_USER function with DEFAULT constraints in the CREATE TABLE and ALTER TABLE statements. You can also use it as any standard function.

If the user name and login name are different, SYSTEM_USER returns the login name.

If the current user is logged in to SQL Server by using Windows Authentication, SYSTEM_USER returns the Windows login identification name in the form: DOMAIN\user_login_name. However, if the current user is logged in to SQL Server by using SQL Server Authentication, SYSTEM_USER returns the SQL Server login identification name, such as WillisJo for a user logged in as WillisJo.

SYSTEM_USER returns the name of the currently executing context. If the EXECUTE AS statement has been used to switch context, SYSTEM_USER returns the name of the impersonated context.

6,CURRENT_USER

Returns the name of the current user. This function is equivalent to USER_NAME().

Syntax

CURRENT_USER

Remarks


CURRENT_USER returns the name of the current security context. If CURRENT_USER is executed after a call to EXECUTE AS switches context, CURRENT_USER will return the name of the impersonated context. If a Windows principal accessed the database by way of membership in a group, the name of the Windows principal will be returned instead of the name of the group.

To return the login of the current user, see SUSER_NAME (Transact-SQL) and SYSTEM_USER (Transact-SQL).

参考文档:

https://msdn.microsoft.com/en-us/library/ms174427.aspx?f=255&MSPPError=-2147217396

时间: 2024-11-09 13:27:32

返回User Name的函数收集的相关文章

js函数收集

常见js函数收集: 转自:http://www.qdfuns.com/notes/36030/2eb2d45cccd4e62020b0a6f0586390af.html //运动框架 function animate(obj,targetJson,time,callback){ if(window.navigator.userAgent.indexOf("MSIE") != -1){ var interval = 50; }else{ var interval = 10; } //得到

Javascript常用方法函数收集(二)

Javascript常用方法函数收集(二) 31.判断是否Touch屏幕 function isTouchScreen(){ return (('ontouchstart' in window) || window.DocumentTouch && document instanceof DocumentTouch); } 32.判断是否打开视窗 function isViewportOpen() { return !!document.getElementById('wixMobileV

c指针 --笔记2返回指针值的函数

返回指针值的函数 一般带回指针值的函数,定义形式为: int *a (int x, int y); 看这个经典案例: #include <stdio.h> int main(int argc, char const *argv[]) { double score[][4] = {{60.0, 70.0, 80.5, 20.1}, {60.0, 70.0, 80.5, 21.1}, {60.0, 70.0, 80.5, 22.1}}; double *search(double(*pointer

【03】指针、返回值、成员函数的const

1 // 2 // 2015-03-05 03/55 3 // 指针.返回值.成员函数 之 const 4 // 5 6 #include <iostream> 7 #include <string> 8 9 using namespace std; 10 11 // ------------------------------ 12 // 1. 指针的const 13 // ------------------------------ 14 const char *p1 = &q

善于指针---使用返回指针值的函数(续)

综合举个例子来说明一下,使用返回指针值的函数,也可以理解为利用指针传递内存. 在返回指针时,除可以返回动态内存外,还可以返回静态存储区.但是不能利用指针传递桟内存,因为桟内存函数结束时也消失了,返回的会是一些垃圾内容,无效. 基础内容见:善于指针---使用返回指针值的函数 //在返回指针时,除可以返回动态内存外,还可以返回静态存储区 #include<iostream> #include<string> using namespace std; //利用指针传值 char *Tes

编程题:返回指针值的函数,求两个数中较大的数。

#include<stdio.h> int *max(int *x,int *y) { int *q; if(*x>*y)  q=x; else  q=y; return q; } void main() { int a,b,*p; scanf("%d,%d",&a,&b); p=max(&a,&b); printf("%d,%d,max is %d\n",a,b,*p); } 编程题:返回指针值的函数,求两个数中较

C++ —— 返回数组指针的函数

基础知识:数组不能被拷贝,函数不能返回数组,只能返回数组的指针或者引用. 定义一个 返回数组指针的函数 的方法,以 一个接收参数为 含有10个整型元素的数组的引用  和 返回一个含有10个整型元素的数组的指针 的函数为例. 法一:(不使用别名) int (*getCopyArr(int (&arr)[10]))[10] { int (*n)[10] = (int (*)[10])new int[10]; for (int i = 0; i < 10; i++) (*n)[i] = arr[i

Shell函数返回值、删除函数、在终端调用函数

Shell 也支持函数.Shell 函数必须先定义后使用. Shell 函数的定义格式如下: function_name () { list of commands [ return value ] } 如果你愿意,也可以在函数名前加上关键字 function: function function_name () { list of commands [ return value ] } 函数返回值,可以显式增加return语句:如果不加,会将最后一条命令运行结果作为返回值. Shell 函数返

Shell函数:Shell函数返回值、删除函数、在终端调用函数

函数可以让我们将一个复杂功能划分成若干模块,让程序结构更加清晰,代码重复利用率更高.像其他编程语言一样,Shell 也支持函数.Shell 函数必须先定义后使用. Shell 函数的定义格式如下: function_name () { list of commands [ return value ] } 如果你愿意,也可以在函数名前加上关键字 function: function function_name () { list of commands [ return value ] } 函数