本文件已封存並已停止維護。
IS_MEMBER (Transact-SQL)
SQL Server 2005
指出目前使用者是指定 Microsoft Windows 群組或 Microsoft SQL Server 資料庫角色的成員。
下列範例會檢查目前使用者是資料庫角色或 Windows 網域群組的成員。
-- Test membership in db_owner and print appropriate message.
IF IS_MEMBER ('db_owner') = 1
print 'Current user is a member of the db_owner role'
ELSE IF IS_MEMBER ('db_owner') = 0
print 'Current user is NOT a member of the db_owner role'
ELSE IF IS_MEMBER ('db_owner') IS NULL
print 'ERROR: Invalid group / role specified'
go
-- Execute SELECT if user is a member of ADVWORKS\Shipping.
IF IS_MEMBER ('ADVWORKS\Shipping') = 1
SELECT 'User ' + USER + ' is a member of ADVWORKS\Shipping.'
go
顯示:

