Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 31 additions & 19 deletions Queue.sql
Original file line number Diff line number Diff line change
@@ -1,23 +1,35 @@
SET ANSI_NULLS ON
SET ANSI_NULLS ON;
GO
SET QUOTED_IDENTIFIER ON

SET QUOTED_IDENTIFIER ON;
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Queue]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[Queue](
[QueueID] [int] IDENTITY(1,1) NOT NULL,
[SchemaName] [sysname] NOT NULL,
[ObjectName] [sysname] NOT NULL,
[Parameters] [nvarchar](max) NOT NULL,
[QueueStartTime] [datetime2](7) NULL,
[SessionID] [smallint] NULL,
[RequestID] [int] NULL,
[RequestStartTime] [datetime] NULL,
CONSTRAINT [PK_Queue] PRIMARY KEY CLUSTERED
(
[QueueID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)

-- Check if the table [dbo].[Queue] already exists
IF NOT EXISTS (
SELECT 1
FROM sys.objects
WHERE object_id = OBJECT_ID(N'[dbo].[Queue]')
AND type = N'U'
)
END
BEGIN
-- Create the [Queue] table
CREATE TABLE [dbo].[Queue] (
[QueueID] INT IDENTITY(1,1) NOT NULL, -- Unique identifier for each queue item
[SchemaName] SYSNAME NOT NULL, -- Schema name of the object
[ObjectName] SYSNAME NOT NULL, -- Object name (e.g., table, procedure)
[Parameters] NVARCHAR(MAX) NOT NULL, -- Parameters for the task
[QueueStartTime] DATETIME2(7) NULL, -- Time when the task was queued
[SessionID] SMALLINT NULL, -- Session ID for the task
[RequestID] INT NULL, -- Identifier for the request
[RequestStartTime] DATETIME NULL, -- Time when the request started processing
CONSTRAINT [PK_Queue] PRIMARY KEY CLUSTERED ([QueueID] ASC)
WITH (
PAD_INDEX = OFF, -- Do not pad the pages of the index
STATISTICS_NORECOMPUTE = OFF, -- Automatically recompute statistics
IGNORE_DUP_KEY = OFF, -- Do not allow duplicate keys
ALLOW_ROW_LOCKS = ON, -- Allow row-level locking
ALLOW_PAGE_LOCKS = ON -- Allow page-level locking
)
);
END;
GO