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]));
From the answer of Yogesh, you can find whether the schema exists or not.
If the schema
items
not exist, try runningIf you don't have permission to create Schema,
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,
Then run the code to create table.
Read Docs here