The idea of the below code is that I feed back to a Gridview if the user has permission to view the property otherwise that property is not show.
The data is passed in via SessionParameters
USE [database]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
alter PROCEDURE [dbo].[spSafeguardingActionPropertyByPermission]
@RegionID bigint
,@EmployeeID varchar(10)
,@PropertyID varchar(10)
AS
BEGIN
SELECT TblA.PropertyID as A_PropertyID,
TblA.Propertyname as A_Propertyname ,
TblB.FireSafety as FireSafety1,
TblB.DisplayScreenEquipment as DSE
FROM TbPropertyDetails as TblA
INNER JOIN TbPropertyDetailsSafeguarding as TblB
ON TblA.PropertyID = TblB.PropertyID
WHERE TblA.RegionID > 0
AND TblA.PropertyID LIKE '%' + @PropertyID + '%'
AND EXISTS
( SELECT 1
FROM tblPropertyViewPermissions AS pvp
WHERE pvp.EmployeeID = @EmployeeID
AND pvp.PropertyID = TblA.PropertyID
)
END