Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Apress
committed
Oct 11, 2016
0 parents
commit 64d63fa
Showing
203 changed files
with
1,499 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
This chapter installs SQL Server and creates additional logon users | ||
|
||
There is no code within this chapter | ||
|
||
Robin Dewson | ||
www.fat-belly.com |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
No code |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
CREATE DATABASE ApressFinancial ON PRIMARY | ||
( NAME = N'ApressFinancial', | ||
FILENAME = 'C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\DATA\ApressFinancial.mdf' , SIZE = 3072KB , | ||
MAXSIZE = UNLIMITED, FILEGROWTH = 1024KB ) | ||
LOG ON | ||
( NAME = 'ApressFinancial_log', | ||
FILENAME = 'C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\DATA\ApressFinancial_log.ldf' , | ||
SIZE = 1024KB , MAXSIZE = 2048GB , FILEGROWTH = 10%) | ||
COLLATE SQL_Latin1_General_CP1_CI_AS | ||
GO |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
USE [master] | ||
GO | ||
CREATE LOGIN [XP-HOME\AJMason] | ||
FROM WINDOWS | ||
GO |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
ALTER LOGIN [XP-HOME\AJMason] | ||
WITH DEFAULT_DATABASE=ApressFinancial | ||
GO |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
CREATE USER [XP-HOME\AJMason] | ||
FOR LOGIN [XP-HOME\AJMason] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
USE ApressFinancial | ||
GO | ||
CREATE SCHEMA TransactionDetails AUTHORIZATION dbo |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
CREATE TABLE TransactionDetails.Transactions | ||
(TransactionId bigint IDENTITY(1,1) NOT NULL, | ||
CustomerId bigint NOT NULL, | ||
TransactionType int NOT NULL, | ||
DateEntered datetime NOT NULL, | ||
Amount numeric(18, 5) NOT NULL, | ||
ReferenceDetails nvarchar(50) NULL, | ||
Notes nvarchar(max) NULL, | ||
RelatedShareId bigint NULL, | ||
RelatedProductId bigint NOT NULL) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
-- ========================================= | ||
-- Create table template | ||
-- ========================================= | ||
USE ApressFinancial | ||
GO | ||
IF OBJECT_ID('TransactionDetails.TransactionTypes', 'U') IS NOT NULL | ||
DROP TABLE TransactionDetails.TransactionTypes | ||
GO | ||
CREATE TABLE TransactionDetails.TransactionTypes( | ||
TransactionTypeId int IDENTITY(1,1) NOT NULL, | ||
TransactionDescription nvarchar(30) NOT NULL, | ||
CreditType bit NOT NULL | ||
) | ||
GO |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
ALTER TABLE TransactionDetails.TransactionTypes | ||
ADD AffectCashBalance bit NULL | ||
GO |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
USE ApressFinancial | ||
GO | ||
CREATE TABLE CustomerDetails.CustomerProducts( | ||
CustomerFinancialProductId bigint NOT NULL, | ||
CustomerId bigint NOT NULL, | ||
FinancialProductId bigint NOT NULL, | ||
AmountToCollect money NOT NULL, | ||
Frequency smallint NOT NULL, | ||
LastCollected datetime NOT NULL, | ||
LastCollection datetime NOT NULL, | ||
Renewable bit NOT NULL | ||
) | ||
ON [PRIMARY] | ||
GO | ||
CREATE TABLE CustomerDetails.FinancialProducts( | ||
ProductId bigint NOT NULL, | ||
ProductName nvarchar(50) NOT NULL | ||
) ON [PRIMARY] | ||
GO | ||
CREATE TABLE ShareDetails.SharePrices( | ||
SharePriceId bigint IDENTITY(1,1) NOT NULL, | ||
ShareId bigint NOT NULL, | ||
Price numeric(18, 5) NOT NULL, | ||
PriceDate datetime NOT NULL | ||
) ON [PRIMARY] | ||
GO | ||
CREATE TABLE ShareDetails.Shares( | ||
ShareId bigint IDENTITY(1,1) NOT NULL, | ||
ShareDesc nvarchar(50) NOT NULL, | ||
ShareTickerId nvarchar(50) NULL, | ||
CurrentPrice numeric(18, 5) NOT NULL | ||
) ON [PRIMARY] | ||
GO |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
ALTER TABLE CustomerDetails.Customers | ||
ADD CONSTRAINT | ||
PK_Customers PRIMARY KEY NONCLUSTERED | ||
( | ||
CustomerId | ||
) | ||
WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, | ||
ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) | ||
ON [PRIMARY] | ||
GO |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
USE ApressFinancial | ||
GO | ||
ALTER TABLE TransactionDetails.Transactions | ||
WITH NOCHECK | ||
ADD CONSTRAINT FK_Transactions_Shares | ||
FOREIGN KEY(RelatedShareId) | ||
REFERENCES ShareDetails.Shares(ShareId) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
USE ApressFinancial | ||
GO | ||
CREATE INDEX IX_CustomerProducts | ||
ON CustomerDetails.CustomerProducts | ||
( | ||
CustomerId | ||
) | ||
GO |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
USE ApressFinancial | ||
GO | ||
CREATE UNIQUE CLUSTERED INDEX IX_TransactionTypes | ||
ON TransactionDetails.TransactionTypes | ||
( | ||
TransactionTypeId ASC ) | ||
WITH (STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, | ||
DROP_EXISTING = OFF, IGNORE_DUP_KEY = OFF, ONLINE = OFF, | ||
ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = OFF) | ||
ON [PRIMARY] | ||
GO | ||
CREATE NONCLUSTERED INDEX IX_Transactions_TType | ||
ON TransactionDetails.Transactions | ||
( | ||
TransactionType ASC) | ||
WITH (STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, | ||
DROP_EXISTING = OFF, IGNORE_DUP_KEY = OFF, ONLINE = OFF, | ||
ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = OFF) | ||
ON [PRIMARY] | ||
GO | ||
ALTER TABLE TransactionDetails.TransactionTypes | ||
ADD CONSTRAINT | ||
PK_TransactionTypes PRIMARY KEY NONCLUSTERED | ||
( | ||
TransactionTypeId | ||
) | ||
WITH (STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, | ||
ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) | ||
ON [PRIMARY] | ||
GO |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
USE ApressFinancial | ||
GO | ||
DROP INDEX IX_TransactionTypes ON TransactionDetails.TransactionTypes | ||
GO | ||
CREATE UNIQUE CLUSTERED INDEX IX_TransactionTypes | ||
ON TransactionDetails.TransactionTypes | ||
( | ||
TransactionTypeId ASC | ||
) WITH (STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, | ||
DROP_EXISTING = OFF, IGNORE_DUP_KEY = OFF, ONLINE = OFF, | ||
ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = OFF) | ||
ON [PRIMARY] | ||
GO |
12 changes: 12 additions & 0 deletions
12
1-59059-720-6/Chapter06/4.ShareDetails.SharePrices-Index.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
USE ApressFinancial | ||
GO | ||
CREATE UNIQUE CLUSTERED INDEX IX_SharePrices | ||
ON ShareDetails.SharePrices | ||
( | ||
ShareId ASC, | ||
PriceDate DESC, | ||
Price | ||
) WITH (STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, | ||
DROP_EXISTING = OFF, IGNORE_DUP_KEY = OFF, ONLINE = OFF, | ||
ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = | ||
OFF, DROP_EXISTING = OFF) ON [PRIMARY] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
USE master | ||
GO | ||
ALTER DATABASE ApressFinancial | ||
SET OFFLINE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
-- Dont forget the FILE = 5 may be different | ||
RESTORE LOG [ApressFinancial] | ||
FROM DISK = 'C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Backup\ApressFinancial.bak' WITH FILE = 5, | ||
NOUNLOAD, STATS = 10 |
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
USE master | ||
go | ||
ALTER DATABASE ApressFinancial | ||
SET ONLINE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
BACKUP DATABASE ApressFinancial | ||
TO DISK = 'C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Backup\ApressFinancial.bak' | ||
WITH NAME = 'ApressFinancial-Full Database Backup', | ||
SKIP, | ||
NOUNLOAD, | ||
STATS = 10 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
BACKUP DATABASE ApressFinancial | ||
TO DISK = 'C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Backup\ApressFinancial.bak' | ||
WITH DIFFERENTIAL , | ||
DESCRIPTION = 'This is a differential backup', | ||
RETAINDAYS = 60, | ||
NAME = 'ApressFinancial-Differential Database Backup', | ||
STATS = 10, | ||
CHECKSUM, | ||
CONTINUE_AFTER_ERROR | ||
GO |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
DECLARE @BackupSet AS INT | ||
SELECT @BackupSet = position | ||
FROM msdb..backupset | ||
WHERE database_name='ApressFinancial' | ||
AND backup_set_id= | ||
(SELECT MAX(backup_set_id) | ||
FROM msdb..backupset | ||
WHERE database_name='ApressFinancial' ) | ||
IF @BackupSet IS NULL | ||
BEGIN | ||
RAISERROR('Verify failed. Backup information for database''ApressFinancial'' not found.', 16, 1) | ||
END | ||
RESTORE VERIFYONLY | ||
FROM DISK = 'C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Backup\ApressFinancial.bak' | ||
WITH FILE = @BackupSet, | ||
NOUNLOAD, | ||
NOREWIND |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
BACKUP LOG ApressFinancial | ||
TO DISK = 'C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Backup\ApressFinancial.bak' | ||
WITH NAME = 'ApressFinancial-Transaction Log Backup', | ||
SKIP, | ||
NOUNLOAD, | ||
STATS = 10 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
ALTER DATABASE ApressFinancial | ||
SET RECOVERY FULL | ||
GO | ||
BACKUP DATABASE ApressFinancial TO DISK = 'C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Backup\ApressFinancial.bak' | ||
WITH NAME = 'ApressFinancial-Full Database Backup' , | ||
SKIP, | ||
NOUNLOAD, | ||
STATS = 10 | ||
GO | ||
BACKUP LOG ApressFinancial | ||
TO DISK = 'C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Backup\ApressFinancial.bak' | ||
WITH NAME = 'ApressFinancial-Transaction Log Backup' , | ||
SKIP, | ||
NOUNLOAD, | ||
STATS = 10 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
USE ApressFinancial | ||
GO | ||
ALTER TABLE ShareDetails.Shares | ||
ADD DummyColumn varchar(30) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
USE Master | ||
GO | ||
-- Dont forget the FILE = 3 may be different | ||
RESTORE DATABASE [ApressFinancial] | ||
FROM DISK = 'C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Backup\ApressFinancial.bak' WITH FILE = 3, | ||
NORECOVERY, NOUNLOAD, REPLACE, STATS = 10 | ||
GO |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
SET QUOTED_IDENTIFIER OFF | ||
GO | ||
INSERT INTO [ApressFinancial].[ShareDetails].[Shares] | ||
([ShareDesc] | ||
,[ShareTickerId] | ||
,[CurrentPrice]) | ||
VALUES | ||
("ACME'S HOMEBAKE COOKIES INC", | ||
'AHCI', | ||
2.34125) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
SELECT CustomerFirstName,CustomerLastName,ClearedBalance | ||
FROM CustomerDetails.Customers |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
SELECT CustomerFirstName As 'First Name', | ||
CustomerLastName AS 'Surname', | ||
ClearedBalance Balance | ||
FROM CustomerDetails.Customers |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
INSERT INTO ShareDetails.Shares | ||
(ShareDesc, ShareTickerId,CurrentPrice) | ||
VALUES ('FAT-BELLY.COM','FBC',45.20) | ||
INSERT INTO ShareDetails.Shares | ||
(ShareDesc, ShareTickerId,CurrentPrice) | ||
VALUES ('NetRadio Inc','NRI',29.79) | ||
INSERT INTO ShareDetails.Shares | ||
(ShareDesc, ShareTickerId,CurrentPrice) | ||
VALUES ('Texas Oil Industries','TOI',0.455) | ||
INSERT INTO ShareDetails.Shares | ||
(ShareDesc, ShareTickerId,CurrentPrice) | ||
VALUES ('London Bridge Club','LBC',1.46) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
SELECT ShareDesc,CurrentPrice | ||
FROM ShareDetails.Shares | ||
WHERE ShareDesc = 'FAT-BELLY.COM' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
SELECT ShareDesc,CurrentPrice | ||
FROM ShareDetails.Shares | ||
WHERE ShareDesc <> 'FAT-BELLY.COM' | ||
|
||
SELECT ShareDesc,CurrentPrice | ||
FROM ShareDetails.Shares | ||
WHERE NOT ShareDesc = 'FAT-BELLY.COM' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
SET ROWCOUNT 3 | ||
SELECT * FROM ShareDetails.Shares | ||
SET ROWCOUNT 0 | ||
SELECT * FROM ShareDetails.Shares |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
SELECT TOP 3 * FROM ShareDetails.Shares | ||
SET ROWCOUNT 3 | ||
SELECT TOP 2 * FROM ShareDetails.Shares | ||
SET ROWCOUNT 2 | ||
SELECT TOP 3 * FROM ShareDetails.Shares |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
SELECT CustomerFirstName + ' ' + CustomerLastName AS 'Name', | ||
ClearedBalance Balance | ||
FROM CustomerDetails.Customers |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
SELECT LEFT(CustomerFirstName + ' ' + CustomerLastName,50) AS 'Name', | ||
ClearedBalance Balance | ||
FROM CustomerDetails.Customers |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
SELECT LEFT(CustomerFirstName + ' ' + CustomerLastName,50) AS 'Name', | ||
ClearedBalance Balance | ||
FROM CustomerDetails.Customers | ||
ORDER BY Balance |
12 changes: 12 additions & 0 deletions
12
1-59059-720-6/Chapter08/2.FixupCustomerDetails.Customers.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
DELETE FROM CustomerDetails.Customers | ||
DBCC CHECKIDENT('CustomerDetails.Customers',RESEED,1) | ||
INSERT INTO CustomerDetails.Customers | ||
(CustomerTitleId,CustomerFirstName,CustomerOtherInitials, | ||
CustomerLastName,AddressId,AccountNumber,AccountTypeId, | ||
ClearedBalance,UnclearedBalance) | ||
VALUES (1,'Vic',NULL,'McGlynn',111,87612311,1,4311.22,213.11) | ||
INSERT INTO CustomerDetails.Customers | ||
(CustomerTitleId,CustomerLastName,CustomerFirstName, | ||
CustomerOtherInitials,AddressId,AccountNumber,AccountTypeId, | ||
ClearedBalance,UnclearedBalance) | ||
VALUES (3,'Mason','Jack',NULL,145,53431993,1,437.97,-10.56) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
SELECT LEFT(CustomerFirstName + ' ' + CustomerLastName,50) AS 'Name', | ||
ClearedBalance Balance | ||
FROM CustomerDetails.Customers | ||
ORDER BY Balance DESC |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
SELECT CustomerFirstName + ' ' + CustomerLastName | ||
FROM CustomerDetails.Customers | ||
WHERE CustomerLastName LIKE '%Glynn' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
SELECT CustomerFirstName + ' ' + CustomerLastName AS [Name] | ||
FROM CustomerDetails.Customers | ||
WHERE CustomerFirstName + ' ' + CustomerLastName LIKE '%n%' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
SELECT CustomerFirstName + ' ' + CustomerLastName AS [Name] | ||
FROM CustomerDetails.Customers | ||
WHERE [Name] LIKE '%n%' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
SELECT CustomerFirstName + ' ' + CustomerLastName AS [Name], | ||
ClearedBalance,UnclearedBalance | ||
INTO CustTemp | ||
FROM CustomerDetails.Customers |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
UPDATE CustomerDetails.Customers | ||
SET CustomerLastName = 'Brodie' | ||
WHERE CustomerId = 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
SELECT * FROM CustomerDetails.Customers | ||
WHERE CustomerId = 1 |
Oops, something went wrong.