· 5 years ago · Apr 18, 2020, 03:26 AM
1/*
2** Copyright Microsoft, Inc. 1994 - 2000
3** All Rights Reserved.
4*/
5SET NOCOUNT ON
6GO
7USE master
8GO
9if exists (select * from sysdatabases where name='Northwind')
10drop database Northwind
11go
12DECLARE @device_directory NVARCHAR(520)
13SELECT @device_directory = SUBSTRING(filename, 1,
14CHARINDEX(N'master.mdf', LOWER(filename)) - 1)
15FROM master.dbo.sysaltfiles WHERE dbid = 1 AND fileid = 1
16EXECUTE (N'CREATE DATABASE Northwind
17 ON PRIMARY (NAME = N''Northwind'', FILENAME = N''' +
18@device_directory + N'northwnd.mdf'')
19 LOG ON (NAME = N''Northwind_log'', FILENAME = N''' +
20@device_directory + N'northwnd.ldf'')')
21go
22alter database Northwind set recovery simple
23GO
24set quoted_identifier on
25GO
26/* Set DATEFORMAT so that the date strings are interpreted correctly
27regardless of
28 the default DATEFORMAT on the server.
29*/
30SET DATEFORMAT mdy
31GO
32use "Northwind"
33go
34if exists (select * from sysobjects where id = object_id('dbo.Employee
35Sales by Country') and sysstat & 0xf = 4)
36drop procedure "dbo"."Employee Sales by Country"
37GO
38if exists (select * from sysobjects where id = object_id('dbo.Sales by
39Year') and sysstat & 0xf = 4)
40drop procedure "dbo"."Sales by Year"
41GO
42if exists (select * from sysobjects where id = object_id('dbo.Ten Most
43Expensive Products') and sysstat & 0xf = 4)
44drop procedure "dbo"."Ten Most Expensive Products"
45GO
46if exists (select * from sysobjects where id = object_id('dbo.Category
47Sales for 1997') and sysstat & 0xf = 2)
48drop view "dbo"."Category Sales for 1997"
49GO
50if exists (select * from sysobjects where id = object_id('dbo.Sales by
51Category') and sysstat & 0xf = 2)
52drop view "dbo"."Sales by Category"
53GO
54if exists (select * from sysobjects where id = object_id('dbo.Sales
55Totals by Amount') and sysstat & 0xf = 2)
56drop view "dbo"."Sales Totals by Amount"
57GO
58if exists (select * from sysobjects where id = object_id('dbo.Summary
59of Sales by Quarter') and sysstat & 0xf = 2)
60drop view "dbo"."Summary of Sales by Quarter"
61GO
62if exists (select * from sysobjects where id = object_id('dbo.Summary
63of Sales by Year') and sysstat & 0xf = 2)
64drop view "dbo"."Summary of Sales by Year"
65GO
66if exists (select * from sysobjects where id =
67object_id('dbo.Invoices') and sysstat & 0xf = 2)
68drop view "dbo"."Invoices"
69GO
70if exists (select * from sysobjects where id = object_id('dbo.Order
71Details Extended') and sysstat & 0xf = 2)
72drop view "dbo"."Order Details Extended"
73GO
74if exists (select * from sysobjects where id = object_id('dbo.Order
75Subtotals') and sysstat & 0xf = 2)
76drop view "dbo"."Order Subtotals"
77GO
78if exists (select * from sysobjects where id = object_id('dbo.Product
79Sales for 1997') and sysstat & 0xf = 2)
80drop view "dbo"."Product Sales for 1997"
81GO
82if exists (select * from sysobjects where id =
83object_id('dbo.Alphabetical list of products') and sysstat & 0xf = 2)
84drop view "dbo"."Alphabetical list of products"
85GO
86if exists (select * from sysobjects where id = object_id('dbo.Current
87Product List') and sysstat & 0xf = 2)
88drop view "dbo"."Current Product List"
89GO
90if exists (select * from sysobjects where id = object_id('dbo.Orders
91Qry') and sysstat & 0xf = 2)
92drop view "dbo"."Orders Qry"
93GO
94if exists (select * from sysobjects where id = object_id('dbo.Products
95Above Average Price') and sysstat & 0xf = 2)
96drop view "dbo"."Products Above Average Price"
97GO
98if exists (select * from sysobjects where id = object_id('dbo.Products
99by Category') and sysstat & 0xf = 2)
100drop view "dbo"."Products by Category"
101GO
102if exists (select * from sysobjects where id =
103object_id('dbo.Quarterly Orders') and sysstat & 0xf = 2)
104drop view "dbo"."Quarterly Orders"
105GO
106if exists (select * from sysobjects where id = object_id('dbo.Customer
107and Suppliers by City') and sysstat & 0xf = 2)
108drop view "dbo"."Customer and Suppliers by City"
109GO
110if exists (select * from sysobjects where id = object_id('dbo.Order
111Details') and sysstat & 0xf = 3)
112drop table "dbo"."Order Details"
113GO
114if exists (select * from sysobjects where id = object_id('dbo.Orders')
115and sysstat & 0xf = 3)
116drop table "dbo"."Orders"
117GO
118if exists (select * from sysobjects where id =
119object_id('dbo.Products') and sysstat & 0xf = 3)
120drop table "dbo"."Products"
121GO
122if exists (select * from sysobjects where id =
123object_id('dbo.Categories') and sysstat & 0xf = 3)
124drop table "dbo"."Categories"
125GO
126if exists (select * from sysobjects where id =
127object_id('dbo.Customers') and sysstat & 0xf = 3)
128drop table "dbo"."Customers"
129GO
130if exists (select * from sysobjects where id =
131object_id('dbo.Shippers') and sysstat & 0xf = 3)
132drop table "dbo"."Shippers"
133GO
134if exists (select * from sysobjects where id =
135object_id('dbo.Suppliers') and sysstat & 0xf = 3)
136drop table "dbo"."Suppliers"
137GO
138if exists (select * from sysobjects where id =
139object_id('dbo.Employees') and sysstat & 0xf = 3)
140drop table "dbo"."Employees"
141GO
142CREATE TABLE "Employees" (
143"EmployeeID" "int" IDENTITY (1, 1) NOT NULL ,
144"LastName" nvarchar (20) NOT NULL ,
145"FirstName" nvarchar (10) NOT NULL ,
146"Title" nvarchar (30) NULL ,
147"TitleOfCourtesy" nvarchar (25) NULL ,
148"BirthDate" "datetime" NULL ,
149"HireDate" "datetime" NULL ,
150"Address" nvarchar (60) NULL ,
151"City" nvarchar (15) NULL ,
152"Region" nvarchar (15) NULL ,
153"PostalCode" nvarchar (10) NULL ,
154"Country" nvarchar (15) NULL ,
155"HomePhone" nvarchar (24) NULL ,
156"Extension" nvarchar (4) NULL ,
157"Photo" "image" NULL ,
158"Notes" "ntext" NULL ,
159"ReportsTo" "int" NULL ,
160"PhotoPath" nvarchar (255) NULL ,
161CONSTRAINT "PK_Employees" PRIMARY KEY CLUSTERED
162("EmployeeID"),
163CONSTRAINT "FK_Employees_Employees" FOREIGN KEY
164("ReportsTo") REFERENCES "dbo"."Employees" ("EmployeeID"),
165CONSTRAINT "CK_Birthdate" CHECK (BirthDate < getdate()))
166GO
167 CREATE INDEX "LastName" ON "dbo"."Employees"("LastName")
168GO
169 CREATE INDEX "PostalCode" ON "dbo"."Employees"("PostalCode")
170GO
171CREATE TABLE "Categories" ("CategoryID" "int" IDENTITY (1, 1) NOT NULL ,"CategoryName" nvarchar (15) NOT NULL ,"Description" "ntext" NULL ,
172"Picture" "image" NULL ,CONSTRAINT "PK_Categories" PRIMARY KEY CLUSTERED("CategoryID"))
173GO
174 CREATE INDEX "CategoryName" ON "dbo"."Categories"("CategoryName")
175GO
176CREATE TABLE "Customers" ("CustomerID" nchar (5) NOT NULL ,
177"CompanyName" nvarchar (40) NOT NULL ,
178"ContactName" nvarchar (30) NULL ,
179"ContactTitle" nvarchar (30) NULL ,
180"Address" nvarchar (60) NULL ,
181"City" nvarchar (15) NULL ,
182"Region" nvarchar (15) NULL ,
183"PostalCode" nvarchar (10) NULL ,
184"Country" nvarchar (15) NULL ,
185"Phone" nvarchar (24) NULL ,
186"Fax" nvarchar (24) NULL ,CONSTRAINT "PK_Customers" PRIMARY KEY CLUSTERED("CustomerID"))
187GO
188 CREATE INDEX "City" ON "dbo"."Customers"("City")
189GO
190 CREATE INDEX "CompanyName" ON "dbo"."Customers"("CompanyName")
191GO
192 CREATE INDEX "PostalCode" ON "dbo"."Customers"("PostalCode")
193GO
194 CREATE INDEX "Region" ON "dbo"."Customers"("Region")
195GO
196CREATE TABLE "Shippers" (
197"ShipperID" "int" IDENTITY (1, 1) NOT NULL ,
198"CompanyName" nvarchar (40) NOT NULL ,
199"Phone" nvarchar (24) NULL ,
200CONSTRAINT "PK_Shippers" PRIMARY KEY CLUSTERED
201("ShipperID"))
202GO
203CREATE TABLE "Suppliers" (
204"SupplierID" "int" IDENTITY (1, 1) NOT NULL ,
205"CompanyName" nvarchar (40) NOT NULL ,
206"ContactName" nvarchar (30) NULL ,
207"ContactTitle" nvarchar (30) NULL ,
208"Address" nvarchar (60) NULL ,
209"City" nvarchar (15) NULL ,
210"Region" nvarchar (15) NULL ,
211"PostalCode" nvarchar (10) NULL ,
212"Country" nvarchar (15) NULL ,
213"Phone" nvarchar (24) NULL ,
214"Fax" nvarchar (24) NULL ,
215"HomePage" "ntext" NULL ,
216CONSTRAINT "PK_Suppliers" PRIMARY KEY CLUSTERED
217("SupplierID"))
218GO
219 CREATE INDEX "CompanyName" ON "dbo"."Suppliers"("CompanyName")
220GO
221 CREATE INDEX "PostalCode" ON "dbo"."Suppliers"("PostalCode")
222GO
223CREATE TABLE "Orders" (
224"OrderID" "int" IDENTITY (1, 1) NOT NULL ,
225"CustomerID" nchar (5) NULL ,
226"EmployeeID" "int" NULL ,
227"OrderDate" "datetime" NULL ,
228"RequiredDate" "datetime" NULL ,
229"ShippedDate" "datetime" NULL ,
230"ShipVia" "int" NULL ,
231"Freight" "money" NULL CONSTRAINT "DF_Orders_Freight" DEFAULT
232(0),
233"ShipName" nvarchar (40) NULL ,
234"ShipAddress" nvarchar (60) NULL ,
235"ShipCity" nvarchar (15) NULL ,
236"ShipRegion" nvarchar (15) NULL ,
237"ShipPostalCode" nvarchar (10) NULL ,
238"ShipCountry" nvarchar (15) NULL ,
239CONSTRAINT "PK_Orders" PRIMARY KEY CLUSTERED
240("OrderID"),
241CONSTRAINT "FK_Orders_Customers" FOREIGN KEY
242("CustomerID") REFERENCES "dbo"."Customers" ("CustomerID"),
243CONSTRAINT "FK_Orders_Employees" FOREIGN KEY
244("EmployeeID") REFERENCES "dbo"."Employees" ("EmployeeID"),
245CONSTRAINT "FK_Orders_Shippers" FOREIGN KEY
246("ShipVia") REFERENCES "dbo"."Shippers" ("ShipperID"))
247GO
248 CREATE INDEX "CustomerID" ON "dbo"."Orders"("CustomerID")
249GO
250 CREATE INDEX "CustomersOrders" ON "dbo"."Orders"("CustomerID")
251GO
252 CREATE INDEX "EmployeeID" ON "dbo"."Orders"("EmployeeID")
253GO
254 CREATE INDEX "EmployeesOrders" ON "dbo"."Orders"("EmployeeID")
255GO
256 CREATE INDEX "OrderDate" ON "dbo"."Orders"("OrderDate")
257GO
258 CREATE INDEX "ShippedDate" ON "dbo"."Orders"("ShippedDate")
259GO
260 CREATE INDEX "ShippersOrders" ON "dbo"."Orders"("ShipVia")
261GO
262 CREATE INDEX "ShipPostalCode" ON "dbo"."Orders"("ShipPostalCode")
263GO
264CREATE TABLE "Products" (
265"ProductID" "int" IDENTITY (1, 1) NOT NULL ,
266"ProductName" nvarchar (40) NOT NULL ,
267"SupplierID" "int" NULL ,
268"CategoryID" "int" NULL ,
269"QuantityPerUnit" nvarchar (20) NULL ,
270"UnitPrice" "money" NULL CONSTRAINT "DF_Products_UnitPrice"
271DEFAULT (0),
272"UnitsInStock" "smallint" NULL CONSTRAINT
273"DF_Products_UnitsInStock" DEFAULT (0),
274"UnitsOnOrder" "smallint" NULL CONSTRAINT
275"DF_Products_UnitsOnOrder" DEFAULT (0),
276"ReorderLevel" "smallint" NULL CONSTRAINT
277"DF_Products_ReorderLevel" DEFAULT (0),
278"Discontinued" "bit" NOT NULL CONSTRAINT
279"DF_Products_Discontinued" DEFAULT (0),
280CONSTRAINT "PK_Products" PRIMARY KEY CLUSTERED
281("ProductID"),
282CONSTRAINT "FK_Products_Categories" FOREIGN KEY
283("CategoryID") REFERENCES "dbo"."Categories" ("CategoryID"),
284CONSTRAINT "FK_Products_Suppliers" FOREIGN KEY
285("SupplierID") REFERENCES "dbo"."Suppliers" ("SupplierID"),
286CONSTRAINT "CK_Products_UnitPrice" CHECK (UnitPrice >= 0),
287CONSTRAINT "CK_ReorderLevel" CHECK (ReorderLevel >= 0),
288CONSTRAINT "CK_UnitsInStock" CHECK (UnitsInStock >= 0),
289CONSTRAINT "CK_UnitsOnOrder" CHECK (UnitsOnOrder >= 0)
290)
291GO
292 CREATE INDEX "CategoriesProducts" ON "dbo"."Products"("CategoryID")
293GO
294 CREATE INDEX "CategoryID" ON "dbo"."Products"("CategoryID")
295GO
296 CREATE INDEX "ProductName" ON "dbo"."Products"("ProductName")
297GO
298 CREATE INDEX "SupplierID" ON "dbo"."Products"("SupplierID")
299GO
300 CREATE INDEX "SuppliersProducts" ON "dbo"."Products"("SupplierID")
301GO
302CREATE TABLE "Order Details" (
303"OrderID" "int" NOT NULL ,
304"ProductID" "int" NOT NULL ,
305"UnitPrice" "money" NOT NULL CONSTRAINT
306"DF_Order_Details_UnitPrice" DEFAULT (0),
307"Quantity" "smallint" NOT NULL CONSTRAINT
308"DF_Order_Details_Quantity" DEFAULT (1),
309"Discount" "real" NOT NULL CONSTRAINT
310"DF_Order_Details_Discount" DEFAULT (0),
311CONSTRAINT "PK_Order_Details" PRIMARY KEY CLUSTERED
312("OrderID","ProductID"),
313CONSTRAINT "FK_Order_Details_Orders" FOREIGN KEY
314("OrderID") REFERENCES "dbo"."Orders" ("OrderID"),
315CONSTRAINT "FK_Order_Details_Products" FOREIGN KEY
316("ProductID") REFERENCES "dbo"."Products" ("ProductID"),
317CONSTRAINT "CK_Discount" CHECK (Discount >= 0 and (Discount <=1)),
318CONSTRAINT "CK_Quantity" CHECK (Quantity > 0),
319CONSTRAINT "CK_UnitPrice" CHECK (UnitPrice >= 0))
320GO
321 CREATE INDEX "OrderID" ON "dbo"."Order Details"("OrderID")
322GO
323 CREATE INDEX "OrdersOrder_Details" ON "dbo"."Order Details"
324("OrderID")
325GO
326 CREATE INDEX "ProductID" ON "dbo"."Order Details"("ProductID")
327GO
328 CREATE INDEX "ProductsOrder_Details" ON "dbo"."Order Details"
329("ProductID")
330GO
331create view "Customer and Suppliers by City" AS
332SELECT City, CompanyName, ContactName, 'Customers' AS Relationship
333FROM Customers
334UNION SELECT City, CompanyName, ContactName, 'Suppliers'
335FROM Suppliers
336--ORDER BY City, CompanyName
337GO
338create view "Alphabetical list of products" AS
339SELECT Products.*, Categories.CategoryName
340FROM Categories INNER JOIN Products ON Categories.CategoryID =
341Products.CategoryID
342WHERE (((Products.Discontinued)=0))
343GO
344create view "Current Product List" AS
345SELECT Product_List.ProductID, Product_List.ProductName
346FROM Products AS Product_List
347WHERE (((Product_List.Discontinued)=0))
348--ORDER BY Product_List.ProductName
349GO
350create view "Orders Qry" AS
351SELECT Orders.OrderID, Orders.CustomerID, Orders.EmployeeID,
352Orders.OrderDate, Orders.RequiredDate,
353Orders.ShippedDate, Orders.ShipVia, Orders.Freight,
354Orders.ShipName, Orders.ShipAddress, Orders.ShipCity,
355Orders.ShipRegion, Orders.ShipPostalCode, Orders.ShipCountry,
356Customers.CompanyName, Customers.Address, Customers.City,
357Customers.Region, Customers.PostalCode, Customers.Country
358FROM Customers INNER JOIN Orders ON Customers.CustomerID =
359Orders.CustomerID
360GO
361create view "Products Above Average Price" AS
362SELECT Products.ProductName, Products.UnitPrice
363FROM Products
364WHERE Products.UnitPrice>(SELECT AVG(UnitPrice) From Products)
365--ORDER BY Products.UnitPrice DESC
366GO
367create view "Products by Category" AS
368SELECT Categories.CategoryName, Products.ProductName,
369Products.QuantityPerUnit, Products.UnitsInStock, Products.Discontinued
370FROM Categories INNER JOIN Products ON Categories.CategoryID =
371Products.CategoryID
372WHERE Products.Discontinued <> 1
373--ORDER BY Categories.CategoryName, Products.ProductName
374GO
375create view "Quarterly Orders" AS
376SELECT DISTINCT Customers.CustomerID, Customers.CompanyName,
377Customers.City, Customers.Country
378FROM Customers RIGHT JOIN Orders ON Customers.CustomerID =
379Orders.CustomerID
380WHERE Orders.OrderDate BETWEEN '19970101' And '19971231'
381GO
382create view Invoices AS
383SELECT Orders.ShipName, Orders.ShipAddress, Orders.ShipCity,
384Orders.ShipRegion, Orders.ShipPostalCode,
385Orders.ShipCountry, Orders.CustomerID, Customers.CompanyName
386AS CustomerName, Customers.Address, Customers.City,
387Customers.Region, Customers.PostalCode, Customers.Country,
388(FirstName + ' ' + LastName) AS Salesperson,
389Orders.OrderID, Orders.OrderDate, Orders.RequiredDate,
390Orders.ShippedDate, Shippers.CompanyName As ShipperName,
391"Order Details".ProductID, Products.ProductName, "Order
392Details".UnitPrice, "Order Details".Quantity,"Order Details".Discount,(CONVERT(money,("Order Details".UnitPrice*Quantity*(1-Discount)/100))*100) AS ExtendedPrice, Orders.Freight
393FROM Shippers INNER JOIN
394(Products INNER JOIN
395((Employees INNER JOIN
396(Customers INNER JOIN Orders
397ON Customers.CustomerID = Orders.CustomerID)
398ON Employees.EmployeeID =
399Orders.EmployeeID)
400INNER JOIN "Order Details" ON Orders.OrderID =
401"Order Details".OrderID)
402ON Products.ProductID = "Order Details".ProductID)
403ON Shippers.ShipperID = Orders.ShipVia
404GO
405create view "Order Details Extended" AS
406SELECT "Order Details".OrderID, "Order Details".ProductID,
407Products.ProductName,
408"Order Details".UnitPrice, "Order Details".Quantity, "Order
409Details".Discount,
410(CONVERT(money,("Order Details".UnitPrice*Quantity*(1-Discount)/100))*100) AS ExtendedPrice
411FROM Products INNER JOIN "Order Details" ON Products.ProductID =
412"Order Details".ProductID
413--ORDER BY "Order Details".OrderID
414GO
415create view "Order Subtotals" AS
416SELECT "Order Details".OrderID, Sum(CONVERT(money,("Order
417Details".UnitPrice*Quantity*(1-Discount)/100))*100) AS Subtotal
418FROM "Order Details"
419GROUP BY "Order Details".OrderID
420GO
421create view "Product Sales for 1997" AS
422SELECT Categories.CategoryName, Products.ProductName,
423Sum(CONVERT(money,("Order Details".UnitPrice*Quantity*(1-
424Discount)/100))*100) AS ProductSales
425FROM (Categories INNER JOIN Products ON Categories.CategoryID =
426Products.CategoryID)
427INNER JOIN (Orders
428INNER JOIN "Order Details" ON Orders.OrderID = "Order
429Details".OrderID)
430ON Products.ProductID = "Order Details".ProductID
431WHERE (((Orders.ShippedDate) Between '19970101' And '19971231'))
432GROUP BY Categories.CategoryName, Products.ProductName
433GO
434create view "Category Sales for 1997" AS
435SELECT "Product Sales for 1997".CategoryName, Sum("Product Sales for
4361997".ProductSales) AS CategorySales
437FROM "Product Sales for 1997"
438GROUP BY "Product Sales for 1997".CategoryName
439GO
440create view "Sales by Category" AS
441SELECT Categories.CategoryID, Categories.CategoryName,
442Products.ProductName,
443Sum("Order Details Extended".ExtendedPrice) AS ProductSales
444FROM Categories INNER JOIN
445(Products INNER JOIN(Orders INNER JOIN "Order Details Extended" ON Orders.OrderID = "Order Details Extended".OrderID)
446ON Products.ProductID = "Order Details Extended".ProductID)
447ON Categories.CategoryID = Products.CategoryID
448WHERE Orders.OrderDate BETWEEN '19970101' And '19971231'
449GROUP BY Categories.CategoryID, Categories.CategoryName,
450Products.ProductName
451--ORDER BY Products.ProductName
452GO
453create view "Sales Totals by Amount" AS
454SELECT "Order Subtotals".Subtotal AS SaleAmount, Orders.OrderID,
455Customers.CompanyName, Orders.ShippedDate
456FROM Customers INNER JOIN
457(Orders INNER JOIN "Order Subtotals" ON Orders.OrderID
458= "Order Subtotals".OrderID)
459ON Customers.CustomerID = Orders.CustomerID
460WHERE ("Order Subtotals".Subtotal >2500) AND (Orders.ShippedDate
461BETWEEN '19970101' And '19971231')
462GO
463create view "Summary of Sales by Quarter" AS
464SELECT Orders.ShippedDate, Orders.OrderID, "Order Subtotals".Subtotal
465FROM Orders INNER JOIN "Order Subtotals" ON Orders.OrderID = "Order
466Subtotals".OrderID
467WHERE Orders.ShippedDate IS NOT NULL
468--ORDER BY Orders.ShippedDate
469GO
470create view "Summary of Sales by Year" AS
471SELECT Orders.ShippedDate, Orders.OrderID, "Order Subtotals".Subtotal
472FROM Orders INNER JOIN "Order Subtotals" ON Orders.OrderID = "Order
473Subtotals".OrderID
474WHERE Orders.ShippedDate IS NOT NULL
475--ORDER BY Orders.ShippedDate
476GO
477create procedure "Ten Most Expensive Products" AS
478SET ROWCOUNT 10
479SELECT Products.ProductName AS TenMostExpensiveProducts,
480Products.UnitPrice
481FROM Products
482ORDER BY Products.UnitPrice DESC
483GO
484create procedure "Employee Sales by Country"
485@Beginning_Date DateTime, @Ending_Date DateTime AS
486SELECT Employees.Country, Employees.LastName, Employees.FirstName,
487Orders.ShippedDate, Orders.OrderID, "Order Subtotals".Subtotal AS
488SaleAmount
489FROM Employees INNER JOIN
490(Orders INNER JOIN "Order Subtotals" ON Orders.OrderID =
491"Order Subtotals".OrderID)
492ON Employees.EmployeeID = Orders.EmployeeID
493WHERE Orders.ShippedDate Between @Beginning_Date And @Ending_Date
494GO
495create procedure "Sales by Year"
496@Beginning_Date DateTime, @Ending_Date DateTime AS
497SELECT Orders.ShippedDate, Orders.OrderID, "Order Subtotals".Subtotal,
498DATENAME(yy,ShippedDate) AS Year
499FROM Orders INNER JOIN "Order Subtotals" ON Orders.OrderID = "Order
500Subtotals".OrderID
501WHERE Orders.ShippedDate Between @Beginning_Date And @Ending_Date
502GO
503set quoted_identifier on
504go
505set identity_insert "Categories" on
506go
507ALTER TABLE "Categories" NOCHECK CONSTRAINT ALL
508go