I have a table: create table #Auths ( AuthId int, ClientId int, ProviderId int)insert into #Authsselect 1, 3046, 5200 union allselect 2, 3048, 5200 union allselect 3, 3052, 5200 union allselect 4, 3053, 5200 union allselect 5, 3046, 6200 union allselect 6, 3046, 7326 union allselect 7, 3050, 7326 union allselect 8, 3051, 5101 union allselect 9, 3053, 6800
From this table I must pull (using a VIEW*) for a given provider (ProviderId) all of the auths that they are allowed to see. A provider is allowed to see all auths (their own and any other providers) for any client (ClientId) that they have a least one auth to.So if I have a view called AvailableAuths Create view AvailableAuthsAs/* here goes the magic code*/ Then my expected results are the following: select AuthId, ClientId, Provider from AvailableAuths where ProviderId = 5200AuthId ClientId ProviderId====== ======== ========== 1 3046 52002 3048 52003 3052 52004 3053 52005 3046 62006 3046 73269 3053 6800select AuthId, ClientId, ProviderId from AvailableAuths where ProviderId = 6200AuthId ClientId ProviderId====== ======== ========== 1 3046 52005 3046 62006 3046 7326select AuthId, ClientId, ProviderId from AvailableAuths where ProviderId = 7326AuthId ClientId ProviderId====== ======== ========== 1 3046 52005 3046 62006 3046 73267 3050 7326
*This must be a view. I do not have the ability to use a stored procedure.Thanks, LaurieEdit: because I missed on row in the expected result list where ProviderId = 5200