title: SQL Server : View permission to table
body: <p>Is it possible to grant a user access to a view but restrict the user from accessing the table the view selects from? </p>
  
  <pre><code>CREATE TABLE [dbo].[tUsers](
      [ID] [int] IDENTITY(1,1) NOT NULL,
      [Username] [nvarchar](50) NULL,
      [Password] [nvarchar](50) NULL,
      [TenantID] int
  ) ON [PRIMARY]
  
  CREATE VIEW [scmTenant1].[vUsers]
  AS
  SELECT     ID, Username, Password
  FROM         dbo.tUsers
  WHERE        TenantID = 1
  </code></pre>
  
  <p>The SQL Server user account (<code>usrTenant1</code>) has access to schema <code>scmTenant1</code> but does not have access to the <code>dbo</code> schema. I log into SQL Server Management Studio as <code>usrTenant1</code> and try executing this query:</p>
  
  <pre><code>SELECT * FROM scmTenant1.vUsers
  </code></pre>
  
  <p>Gives me error:</p>
  
  <blockquote>
    <p><em>The SELECT permission was denied on the object 'tUsers', database 'Sandbox', schema 'dbo'.</em> </p>
  </blockquote>
  
  <p>If I grant this account access to the <code>dbo</code> schema the query executes fine.</p>
  
  <p>I think what I would really like to grant the view permission to the table. But my question is can you grant a user access to a view and restrict that user from accessing the underlying table the view selects from?</p>