SQLize Online / PHPize Online  /  SQLtest Online

A A A
Share      Blog   Popular
Copy Format Clear
SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE TABLE AWBuildVersion( SystemInformationID tinyint IDENTITY(1,1) NOT NULL, [Database Version] nvarchar(25) NOT NULL, VersionDate datetime NOT NULL, ModifiedDate datetime NOT NULL, CONSTRAINT PK_AWBuildVersion_SystemInformationID PRIMARY KEY CLUSTERED ( SystemInformationID ASC ) ) GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE TABLE DatabaseLog( DatabaseLogID int IDENTITY(1,1) NOT NULL, PostTime datetime NOT NULL, DatabaseUser sysname NOT NULL, Event sysname NOT NULL, [Schema] sysname NULL, Object sysname NULL, TSQL nvarchar(max) NOT NULL, XmlEvent xml NOT NULL, CONSTRAINT PK_DatabaseLog_DatabaseLogID PRIMARY KEY NONCLUSTERED ( DatabaseLogID ASC ) ) GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE TABLE ErrorLog( ErrorLogID int IDENTITY(1,1) NOT NULL, ErrorTime datetime NOT NULL, UserName sysname NOT NULL, ErrorNumber int NOT NULL, ErrorSeverity int NULL, ErrorState int NULL, ErrorProcedure nvarchar(126) NULL, ErrorLine int NULL, ErrorMessage nvarchar(4000) NOT NULL, CONSTRAINT PK_ErrorLog_ErrorLogID PRIMARY KEY CLUSTERED ( ErrorLogID ASC ) ) GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE TABLE Department( DepartmentID smallint IDENTITY(1,1) NOT NULL, Name VARCHAR(50) NOT NULL, GroupName VARCHAR(50) NOT NULL, ModifiedDate datetime NOT NULL, CONSTRAINT PK_Department_DepartmentID PRIMARY KEY CLUSTERED ( DepartmentID ASC ) ) GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE TABLE Employee( BusinessEntityID int NOT NULL, NationalIDNumber nvarchar(15) NOT NULL, LoginID nvarchar(256) NOT NULL, OrganizationNode hierarchyid NULL, OrganizationLevel AS (OrganizationNode.GetLevel()), JobTitle nvarchar(50) NOT NULL, BirthDate date NOT NULL, MaritalStatus nchar(1) NOT NULL, Gender nchar(1) NOT NULL, HireDate date NOT NULL, SalariedFlag bit NOT NULL, VacationHours smallint NOT NULL, SickLeaveHours smallint NOT NULL, CurrentFlag bit NOT NULL, rowguid uniqueidentifier ROWGUIDCOL NOT NULL, ModifiedDate datetime NOT NULL, CONSTRAINT PK_Employee_BusinessEntityID PRIMARY KEY CLUSTERED ( BusinessEntityID ASC ) ) GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE TABLE EmployeeDepartmentHistory( BusinessEntityID int NOT NULL, DepartmentID smallint NOT NULL, ShiftID tinyint NOT NULL, StartDate date NOT NULL, EndDate date NULL, ModifiedDate datetime NOT NULL, CONSTRAINT PK_EmployeeDepartmentHistory_BusinessEntityID_StartDate_DepartmentID PRIMARY KEY CLUSTERED ( BusinessEntityID ASC, StartDate ASC, DepartmentID ASC, ShiftID ASC ) ) GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE TABLE EmployeePayHistory( BusinessEntityID int NOT NULL, RateChangeDate datetime NOT NULL, Rate money NOT NULL, PayFrequency tinyint NOT NULL, ModifiedDate datetime NOT NULL, CONSTRAINT PK_EmployeePayHistory_BusinessEntityID_RateChangeDate PRIMARY KEY CLUSTERED ( BusinessEntityID ASC, RateChangeDate ASC ) ) GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE TABLE JobCandidate( JobCandidateID int IDENTITY(1,1) NOT NULL, BusinessEntityID int NULL, Resume xml(CONTENT HRResumeSchemaCollection) NULL, ModifiedDate datetime NOT NULL, CONSTRAINT PK_JobCandidate_JobCandidateID PRIMARY KEY CLUSTERED ( JobCandidateID ASC ) ) TEXTIMAGE_ON PRIMARY GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE TABLE Shift( ShiftID tinyint IDENTITY(1,1) NOT NULL, Name varchar (50) NOT NULL, StartTime time(7) NOT NULL, EndTime time(7) NOT NULL, ModifiedDate datetime NOT NULL, CONSTRAINT PK_Shift_ShiftID PRIMARY KEY CLUSTERED ( ShiftID ASC ) ) GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE SCHEMA person GO CREATE TABLE Person.Address( AddressID int IDENTITY(1,1) NOT FOR REPLICATION NOT NULL, AddressLine1 nvarchar(60) NOT NULL, AddressLine2 nvarchar(60) NULL, City nvarchar(30) NOT NULL, StateProvinceID int NOT NULL, PostalCode nvarchar(15) NOT NULL, SpatialLocation geography NULL, rowguid uniqueidentifier ROWGUIDCOL NOT NULL, ModifiedDate datetime NOT NULL, CONSTRAINT PK_Address_AddressID PRIMARY KEY CLUSTERED ( AddressID ASC ) TEXTIMAGE_ON PRIMARY GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE TABLE Person.AddressType( AddressTypeID int IDENTITY(1,1) NOT NULL, Name varchar (50) NOT NULL, rowguid uniqueidentifier ROWGUIDCOL NOT NULL, ModifiedDate datetime NOT NULL, CONSTRAINT PK_AddressType_AddressTypeID PRIMARY KEY CLUSTERED ( AddressTypeID ASC ) ) GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE TABLE Person.BusinessEntity( BusinessEntityID int IDENTITY(1,1) NOT FOR REPLICATION NOT NULL, rowguid uniqueidentifier ROWGUIDCOL NOT NULL, ModifiedDate datetime NOT NULL, CONSTRAINT PK_BusinessEntity_BusinessEntityID PRIMARY KEY CLUSTERED ( BusinessEntityID ASC ) ) GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE TABLE Person.BusinessEntityAddress( BusinessEntityID int NOT NULL, AddressID int NOT NULL, AddressTypeID int NOT NULL, rowguid uniqueidentifier ROWGUIDCOL NOT NULL, ModifiedDate datetime NOT NULL, CONSTRAINT PK_BusinessEntityAddress_BusinessEntityID_AddressID_AddressTypeID PRIMARY KEY CLUSTERED ( BusinessEntityID ASC, AddressID ASC, AddressTypeID ASC ) ) GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE TABLE Person.BusinessEntityContact( BusinessEntityID int NOT NULL, PersonID int NOT NULL, ContactTypeID int NOT NULL, rowguid uniqueidentifier ROWGUIDCOL NOT NULL, ModifiedDate datetime NOT NULL, CONSTRAINT PK_BusinessEntityContact_BusinessEntityID_PersonID_ContactTypeID PRIMARY KEY CLUSTERED ( BusinessEntityID ASC, PersonID ASC, ContactTypeID ASC ) ) GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE TABLE Person.ContactType( ContactTypeID int IDENTITY(1,1) NOT NULL, Name varchar (50) NOT NULL, ModifiedDate datetime NOT NULL, CONSTRAINT PK_ContactType_ContactTypeID PRIMARY KEY CLUSTERED ( ContactTypeID ASC ) ) GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE TABLE Person.CountryRegion( CountryRegionCode nvarchar(3) NOT NULL, Name varchar (50) NOT NULL, ModifiedDate datetime NOT NULL, CONSTRAINT PK_CountryRegion_CountryRegionCode PRIMARY KEY CLUSTERED ( CountryRegionCode ASC ) ) GO /****** Object: Table Person.EmailAddress Script Date: 1/21/2022 3:49:03 PM ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE TABLE Person.EmailAddress( BusinessEntityID int NOT NULL, EmailAddressID int IDENTITY(1,1) NOT NULL, EmailAddress nvarchar(50) NULL, rowguid uniqueidentifier ROWGUIDCOL NOT NULL, ModifiedDate datetime NOT NULL, CONSTRAINT PK_EmailAddress_BusinessEntityID_EmailAddressID PRIMARY KEY CLUSTERED ( BusinessEntityID ASC, EmailAddressID ASC ) ) GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE TABLE Person.Password( BusinessEntityID int NOT NULL, PasswordHash varchar(128) NOT NULL, PasswordSalt varchar(10) NOT NULL, rowguid uniqueidentifier ROWGUIDCOL NOT NULL, ModifiedDate datetime NOT NULL, CONSTRAINT PK_Password_BusinessEntityID PRIMARY KEY CLUSTERED ( BusinessEntityID ASC ) ) GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE TABLE Person.Person( BusinessEntityID int NOT NULL, PersonType nchar(2) NOT NULL, NameStyle NameStyle NOT NULL, Title nvarchar(8) NULL, FirstName Name NOT NULL, MiddleName Name NULL, LastName Name NOT NULL, Suffix nvarchar(10) NULL, EmailPromotion int NOT NULL, AdditionalContactInfo xml(CONTENT Person.AdditionalContactInfoSchemaCollection) NULL, Demographics xml(CONTENT Person.IndividualSurveySchemaCollection) NULL, rowguid uniqueidentifier ROWGUIDCOL NOT NULL, ModifiedDate datetime NOT NULL, CONSTRAINT PK_Person_BusinessEntityID PRIMARY KEY CLUSTERED ( BusinessEntityID ASC ) ) TEXTIMAGE_ON PRIMARY GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE TABLE Person.PersonPhone( BusinessEntityID int NOT NULL, PhoneNumber varchar (10) NOT NULL, PhoneNumberTypeID int NOT NULL, ModifiedDate datetime NOT NULL, CONSTRAINT PK_PersonPhone_BusinessEntityID_PhoneNumber_PhoneNumberTypeID PRIMARY KEY CLUSTERED ( BusinessEntityID ASC, PhoneNumber ASC, PhoneNumberTypeID ASC ) ) GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE TABLE Person.PhoneNumberType( PhoneNumberTypeID int IDENTITY(1,1) NOT NULL, Name varchar (50) NOT NULL, ModifiedDate datetime NOT NULL, CONSTRAINT PK_PhoneNumberType_PhoneNumberTypeID PRIMARY KEY CLUSTERED ( PhoneNumberTypeID ASC ) ) GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE TABLE Person.StateProvince( StateProvinceID int IDENTITY(1,1) NOT NULL, StateProvinceCode nchar(3) NOT NULL, CountryRegionCode nvarchar(3) NOT NULL, IsOnlyStateProvinceFlag varchar(50) NOT NULL, Name varchar (50) NOT NULL, TerritoryID int NOT NULL, rowguid uniqueidentifier ROWGUIDCOL NOT NULL, ModifiedDate datetime NOT NULL, CONSTRAINT PK_StateProvince_StateProvinceID PRIMARY KEY CLUSTERED ( StateProvinceID ASC ) ) GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO /****** Object: Table Purchasing.ProductVendor Script Date: 1/21/2022 3:49:03 PM ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE SCHEMA purchasing GO CREATE TABLE Purchasing.ProductVendor( ProductID int NOT NULL, BusinessEntityID int NOT NULL, AverageLeadTime int NOT NULL, StandardPrice money NOT NULL, LastReceiptCost money NULL, LastReceiptDate datetime NULL, MinOrderQty int NOT NULL, MaxOrderQty int NOT NULL, OnOrderQty int NULL, UnitMeasureCode nchar(3) NOT NULL, ModifiedDate datetime NOT NULL, CONSTRAINT PK_ProductVendor_ProductID_BusinessEntityID PRIMARY KEY CLUSTERED ( ProductID ASC, BusinessEntityID ASC ) ) GO /****** Object: Table Purchasing.PurchaseOrderDetail Script Date: 1/21/2022 3:49:03 PM ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE TABLE Purchasing.PurchaseOrderDetail( PurchaseOrderID int NOT NULL, PurchaseOrderDetailID int IDENTITY(1,1) NOT NULL, DueDate datetime NOT NULL, OrderQty smallint NOT NULL, ProductID int NOT NULL, UnitPrice money NOT NULL, LineTotal AS (isnull(OrderQty*UnitPrice,(0.00))), ReceivedQty decimal(8, 2) NOT NULL, RejectedQty decimal(8, 2) NOT NULL, StockedQty AS (isnull(ReceivedQty-RejectedQty,(0.00))), ModifiedDate datetime NOT NULL, CONSTRAINT PK_PurchaseOrderDetail_PurchaseOrderID_PurchaseOrderDetailID PRIMARY KEY CLUSTERED ( PurchaseOrderID ASC, PurchaseOrderDetailID ASC ) ) GO /****** Object: Table Purchasing.PurchaseOrderHeader Script Date: 1/21/2022 3:49:03 PM ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE TABLE Purchasing.PurchaseOrderHeader( PurchaseOrderID int IDENTITY(1,1) NOT NULL, RevisionNumber tinyint NOT NULL, Status tinyint NOT NULL, EmployeeID int NOT NULL, VendorID int NOT NULL, ShipMethodID int NOT NULL, OrderDate datetime NOT NULL, ShipDate datetime NULL, SubTotal money NOT NULL, TaxAmt money NOT NULL, Freight money NOT NULL, TotalDue AS (isnull((SubTotal+TaxAmt)+Freight,(0))) PERSISTED NOT NULL, ModifiedDate datetime NOT NULL, CONSTRAINT PK_PurchaseOrderHeader_PurchaseOrderID PRIMARY KEY CLUSTERED ( PurchaseOrderID ASC ) ) GO /****** Object: Table Purchasing.ShipMethod Script Date: 1/21/2022 3:49:03 PM ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE TABLE Purchasing.ShipMethod( ShipMethodID int IDENTITY(1,1) NOT NULL, Name varchar (50) NOT NULL, ShipBase money NOT NULL, ShipRate money NOT NULL, rowguid uniqueidentifier ROWGUIDCOL NOT NULL, ModifiedDate datetime NOT NULL, CONSTRAINT PK_ShipMethod_ShipMethodID PRIMARY KEY CLUSTERED ( ShipMethodID ASC ) ) GO /****** Object: Table Purchasing.Vendor Script Date: 1/21/2022 3:49:03 PM ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE TABLE Purchasing.Vendor( BusinessEntityID int NOT NULL, AccountNumber int NOT NULL, Name varchar (50) NOT NULL, CreditRating tinyint NOT NULL, PreferredVendorStatus int NOT NULL, ActiveFlag int NOT NULL, PurchasingWebServiceURL nvarchar(1024) NULL, ModifiedDate datetime NOT NULL, CONSTRAINT PK_Vendor_BusinessEntityID PRIMARY KEY CLUSTERED ( BusinessEntityID ASC ) )
Stuck with a problem? Got Error? Ask ChatGPT!
Copy Clear