BEGIN TRANSACTION;
-- Table creation with multiple issues
CREATE TABLE Orders (
OrderID INT PRIMARY KEY NOT NULL,
CustomerID INT NOT NULL,
OrderDate DATETIME DEFAULT GETDATE(),
TotalAmount DECIMAL(10, 2) NOT NULL,
ShippedDate DATETIME DEFAULT NULL
);
-- This part introduces an incorrect foreign key constraint
ALTER TABLE Orders
BEGIN TRANSACTION;
-- Table creation with multiple issues
CREATE TABLE Orders (
OrderID INT PRIMARY KEY NOT NULL,
CustomerID INT NOT NULL,
OrderDate DATETIME DEFAULT GETDATE(),
TotalAmount DECIMAL(10, 2) NOT NULL,
ShippedDate DATETIME DEFAULT NULL
);
-- This part introduces an incorrect foreign key constraint
ALTER TABLE Orders
ADD CONSTRAINT FK_CustomerOrders
FOREIGN KEY (CustomerID)
REFERENCES Customers(CustomerID) -- Syntax issue: Missing closing parenthesis or extra comma