Function:
[AdventureWorks2016CTP3].[Security].[customerAccessPredicate]
Name | Value |
Schema | [Security] |
Owner | [dbo] |
Creation date | 23.10.2015 |
Type | Inline |
Is schema bound | ![]() |
Is deterministic | |
Encrypted | |
Implementation type | Transact SQL |
ID | 1678629023 |
Name | Value |
QUOTED_IDENTIFIER | ON |
ANSI_NULLS | ON |
Name | Description | DataType | Max length | ReadOnly |
@TerritoryID | int | 4 |
Name | Datatype | Max length |
accessResult | int | 4 |
Object name | Object type | Dep level |
[Security] | Schema | 1 |
[HumanResources].[Employee] | Table | 1 |
[Sales].[SalesPerson] | Table | 1 |
SET ANSI_NULLS ON SET QUOTED_IDENTIFIER ON GO CREATE FUNCTION Security.customerAccessPredicate(@TerritoryID int) RETURNS TABLE WITH SCHEMABINDING AS RETURN SELECT 1 AS accessResult FROM HumanResources.Employee e INNER JOIN Sales.SalesPerson sp ON sp.BusinessEntityID = e.BusinessEntityID WHERE ( RIGHT(e.LoginID, LEN(e.LoginID) - LEN('adventure-works\')) = USER_NAME() AND sp.TerritoryID = @TerritoryID ) OR IS_MEMBER('SalesManagers') = 1 OR IS_MEMBER('db_owner') = 1 GO |