The INSERT permission was denied on the object 'Driver'

12,534
-- Use master
USE msdb;
go

-- Make database
CREATE DATABASE SuburbanPortal2;
go

-- Use the database
USE SuburbanPortal2;
GO

-- Make schema
CREATE SCHEMA Truck AUTHORIZATION dbo;
go

-- Make table
CREATE TABLE Truck.Driver
(
    [DriverId] uniqueidentifier,
    [CorporationId] uniqueidentifier,
    [DriverNumber] varchar(64),
    [Name] varchar(128),
    [PhoneNumber] varchar(12)
);

-- Add data
INSERT [Truck].[Driver] ([DriverId], [CorporationId], [DriverNumber], [Name], [PhoneNumber]) 
VALUES (N'b78f90a6-ed6d-4f0e-9f35-1f3e9c516ca9', N'0a48eeeb-37f6-44de-aff5-fe9107d821f5', N'12', N'Unknown', NULL);
GO

This code setups a sample database like you have. I have no issues with the insert.

Who is the owner of the schema??

If you want to hide tables from one database group and another, add your user to the database group.

Make the database group the owner of the schema. I think you might be having a schema ownership issue ...

Can you drill into database -> security -> schemas -> Truck, right click and show me the owner of the schema. Please post image.

Also, remove all database permissions from the user except for db_owner.

Share:
12,534
ErocM
Author by

ErocM

Updated on June 11, 2022

Comments

  • ErocM
    ErocM about 2 years

    I am trying to run the following script from SQL Server Management Studio:

    INSERT [Truck].[Driver] ([DriverId], [CorporationId], [DriverNumber], [Name], [PhoneNumber]) 
    VALUES (N'b78f90a6-ed6d-4f0e-9f35-1f3e9c516ca9', N'0a48eeeb-37f6-44de-aff5-fe9107d821f5', N'12', N'Unknown', NULL)
    

    And I'm getting this error:

    Msg 229, Level 14, State 5, Line 1
    The INSERT permission was denied on the object 'Driver', database 'SuburbanPortal2', schema 'Truck'.

    I can manually add this in edit mode and I get no errors. I have every permission I can think of set for my users. This is a local database logging in as a local user that I'm testing some data on so I could care less about security.

    But, here are the settings for the database for my user:

    enter image description here

    enter image description here

    enter image description here

    Any suggestions?