From 875cc6c1ef62c43858f5677b3fd7947d23e20cda Mon Sep 17 00:00:00 2001 From: Imran Imtiaz Date: Sun, 29 Dec 2024 07:52:02 +0400 Subject: [PATCH] Update Queue.sql MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Improvements 1. Comments: o Added inline comments for each column to explain its purpose. o Provided comments on constraints and index options for clarity. 2. Readability: o Improved formatting by aligning columns and properties for better readability. o Used consistent indentation and spacing. 3. Description: o Provided clear descriptions for the script’s purpose and behavior. --- Queue.sql | 50 +++++++++++++++++++++++++++++++------------------- 1 file changed, 31 insertions(+), 19 deletions(-) diff --git a/Queue.sql b/Queue.sql index e8374df6..0bc90b28 100644 --- a/Queue.sql +++ b/Queue.sql @@ -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 -