Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Msg 2760, Level 16, State 1, Line 5 The specified schema name "items" either does not exist or you do not have permission to use it

I am trying to create a temporal table in my SQL Server database. Is anyone familiar with this error in SQL Server:

Msg 2760, Level 16, State 1, Line 5 The specified schema name "items" either does not exist or you do not have permission to use it.

I think there may be something wrong with my user privileges. Any help would be great.

Here's the code:

CREATE TABLE [items].[items_Temporal](
    [itemsID] [int] NOT NULL, 
    [item_Name] [varchar](50) NOT NULL, 
    [item_Number] [int] NOT NULL, 
    [item_Price] [float] NOT NULL, 
    ValidFrom datetime2(7) GENERATED ALWAYS AS ROW START HIDDEN NOT NULL, 
    ValidTo datetime2(7) GENERATED ALWAYS AS ROW END HIDDEN NOT NULL,

    CONSTRAINT [PK_items_Temporal_items1ID] PRIMARY KEY CLUSTERED
    (
        [itemsID] ASC
    ), 
    PERIOD FOR SYSTEM_TIME(ValidFrom, ValidTo)
)

WITH(SYSTEM_VERSIONING = ON (HISTORY_TABLE = [items].[items_Temporal_History])); 
like image 603
HelloWoRlD Avatar asked Dec 07 '25 08:12

HelloWoRlD


1 Answers

From the answer of Yogesh, you can find whether the schema exists or not.

If the schema items not exist, try running

CREATE SCHEMA items

If you don't have permission to create Schema,

USE <database_name>;  
    GRANT CREATE SCHEMA TO <user_name>;  
GO 

Then create schema and run the code for creating the table.

In the case you have the schema and you are not having the permission to use it,

USE <database_name>;  
    GRANT CREATE TABLE TO <user_name>;  
GO 

Then run the code to create table.

Read Docs here

like image 106
jophab Avatar answered Dec 09 '25 21:12

jophab



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!