Here is the sql for creating a schema, a view belonging to that schema a log in and a user
create schema HumanResources
Create view HumanResources.vw_EmployeeInfo
As
Select
SSNumber,
LastName as [Last Name],
FirstName as [First Name],
Street,
Apartment,
ContactInfo,
HireDate,
Dependents
From Person p
inner Join PersonAddress pa
on p.PersonKey=pa.PersonKey
inner Join PersonContact pc
on p.PersonKey=pc.PersonKey
inner join Employee e
on p.PersonKey=e.PersonKey
select * from HumanResources.vw_EmployeeInfo
Create login Sue with password='p@ssw0rd1'
Create user SueUser for login Sue with default_schema=HumanResources
Grant Select on Schema::HumanResources to SueUser
Now login as your user and test the view
Select * from vw_EmployeeInfo
No comments:
Post a Comment