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 d183a66
Showing
475 changed files
with
144,051 additions
and
0 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,27 @@ | ||
Freeware License, some rights reserved | ||
|
||
Copyright (c) 2007 Michael Coles | ||
|
||
Permission is hereby granted, free of charge, to anyone obtaining a copy | ||
of this software and associated documentation files (the "Software"), | ||
to work with the Software within the limits of freeware distribution and fair use. | ||
This includes the rights to use, copy, and modify the Software for personal use. | ||
Users are also allowed and encouraged to submit corrections and modifications | ||
to the Software for the benefit of other users. | ||
|
||
It is not allowed to reuse, modify, or redistribute the Software for | ||
commercial use in any way, or for a user�s educational materials such as books | ||
or blog articles without prior permission from the copyright holder. | ||
|
||
The above copyright notice and this permission notice need to be included | ||
in all copies or substantial portions of the software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS OR APRESS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. | ||
|
||
|
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 @@ | ||
#Apress Source Code | ||
|
||
This repository accompanies [*Pro T-SQL 2005 Programmer's Guide*](http://www.apress.com/9781590597941) by Michael Coles (Apress, 2007). | ||
|
||
![Cover image](9781590597941.jpg) | ||
|
||
Download the files as a zip using the green button, or clone the repository to your machine using Git. | ||
|
||
##Releases | ||
|
||
Release v1.0 corresponds to the code in the published book, without corrections or updates. | ||
|
||
##Contributions | ||
|
||
See the file Contributing.md for more information on how you can contribute to this repository. |
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,9 @@ | ||
-- Sample program Listing 1-10 from Chapter 1 | ||
|
||
USE AdventureWorks; | ||
GO | ||
SELECT o.name | ||
FROM sys.objects o | ||
LEFT JOIN sys.views v | ||
ON o.object_id = v.object_id; | ||
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,9 @@ | ||
-- Sample program Listing 1-11 from Chapter 1 | ||
|
||
USE AdventureWorks; | ||
GO | ||
-- @i is not initialized, so the end result is @i = NULL | ||
DECLARE @i INT; | ||
SELECT @i = @i + 5; | ||
SELECT @i; | ||
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 @@ | ||
-- Sample program Listing 1-12 from Chapter 1 | ||
|
||
USE AdventureWorks; | ||
GO | ||
-- @i is initialized to 0, so the end result is @i = 5 | ||
DECLARE @i INT; | ||
SELECT @i = 0; -- Added this statement to initialize @i to 0 | ||
SELECT @i = @i + 5; | ||
SELECT @i; | ||
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 @@ | ||
-- Sample program Listing 1-2 from Chapter 1 | ||
|
||
USE AdventureWorks; | ||
GO | ||
SELECT FirstName | ||
FROM Person.Contact; | ||
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,22 @@ | ||
-- Sample program Listing 1-3 from Chapter 1 | ||
|
||
USE AdventureWorks; | ||
GO | ||
SELECT [HumanResources].[Employee].[EmployeeID], [Person].[Contact].[Title], | ||
[Person].[Contact].[FirstName], [Person].[Contact].[MiddleName], | ||
[Person].[Contact].[LastName], [Person].[Contact].[Suffix], | ||
[HumanResources].[Employee].[Title] AS [JobTitle], [Person].[Contact].[Phone], | ||
[Person].[Contact].[EmailAddress], [Person].[Contact].[EmailPromotion], | ||
[Person].[Address].[AddressLine1], [Person].[Address].[AddressLine2], | ||
[Person].[Address].[City], [Person].[StateProvince].[Name] AS [StateProvinceName], | ||
[Person].[Address].[PostalCode], [Person].[CountryRegion].[Name] AS | ||
[CountryRegionName], [Person].[Contact].[AdditionalContactInfo] FROM | ||
[HumanResources].[Employee] INNER JOIN [Person].[Contact] ON | ||
[Person].[Contact].[ContactID] = [HumanResources].[Employee].[ContactID] INNER JOIN | ||
[HumanResources].[EmployeeAddress] ON [HumanResources].[Employee].[EmployeeID] = | ||
[HumanResources].[EmployeeAddress].[EmployeeID] INNER JOIN [Person].[Address] ON | ||
[HumanResources].[EmployeeAddress].[AddressID] = [Person].[Address].[AddressID] INNER | ||
JOIN [Person].[StateProvince] ON [Person].[StateProvince].[StateProvinceID] = | ||
[Person].[Address].[StateProvinceID] INNER JOIN [Person].[CountryRegion] ON | ||
[Person].[CountryRegion].[CountryRegionCode] = [Person].[StateProvince].[CountryRegionCode] | ||
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 @@ | ||
-- Sample program Listing 1-4 from Chapter 1 | ||
|
||
USE AdventureWorks; | ||
GO | ||
SELECT e.EmployeeID, | ||
c.Title, | ||
c.FirstName, | ||
c.MiddleName, | ||
c.LastName, | ||
c.Suffix, | ||
e.Title AS JobTitle, | ||
c.Phone, | ||
c.EmailAddress, | ||
c.EmailPromotion, | ||
a.AddressLine1, | ||
a.AddressLine2, | ||
a.City, | ||
sp.Name AS StateProvinceName, | ||
a.PostalCode, | ||
cr.Name AS CountryRegionName, | ||
c.AdditionalContactInfo | ||
FROM HumanResources.Employee e | ||
INNER JOIN Person.Contact c | ||
ON c.ContactID = e.ContactID | ||
INNER JOIN HumanResources.EmployeeAddress ea | ||
ON e.EmployeeID = ea.EmployeeID | ||
INNER JOIN Person.Address a | ||
ON ea.AddressID = a.AddressID | ||
INNER JOIN Person.StateProvince sp | ||
ON sp.StateProvinceID = a.StateProvinceID | ||
INNER JOIN Person.CountryRegion cr | ||
ON cr.CountryRegionCode = sp.CountryRegionCode; | ||
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 @@ | ||
-- Sample program Listing 1-5 from Chapter 1 | ||
|
||
USE AdventureWorks; | ||
GO | ||
SELECT I.CUSTOMERID, C.TITLE, C.FIRSTNAME, C.MIDDLENAME, | ||
C.LASTNAME, C.SUFFIX, C.PHONE, C.EMAILADDRESS, | ||
C.EMAILPROMOTION | ||
FROM SALES.INDIVIDUAL I | ||
INNER JOIN PERSON.CONTACT C | ||
ON C.CONTACTID = I.CONTACTID | ||
INNER JOIN SALES.CUSTOMERADDRESS CA | ||
ON CA.CUSTOMERID = I.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,19 @@ | ||
-- Sample program Listing 1-6 from Chapter 1 | ||
|
||
USE AdventureWorks; | ||
GO | ||
SELECT i.CustomerID, | ||
c.Title, | ||
c.FirstName, | ||
c.MiddleName, | ||
c.LastName, | ||
c.Suffix, | ||
c.Phone, | ||
c.EmailAddress, | ||
c.EmailPromotion | ||
FROM Sales.Individual i | ||
INNER JOIN Person.Contact c | ||
ON c.ContactID = i.ContactID | ||
INNER JOIN Sales.CustomerAddress ca | ||
ON ca.CustomerID = i.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,35 @@ | ||
-- Sample program Listing 1-7 from Chapter 1 | ||
|
||
USE AdventureWorks; | ||
GO | ||
IF OBJECT_ID('dbo.GetOrAdd_ContactType') IS NOT NULL | ||
DROP PROCEDURE dbo.GetOrAdd_ContactType; | ||
GO | ||
CREATE PROCEDURE dbo.GetOrAdd_ContactType | ||
( | ||
@Name NVARCHAR(50), | ||
@ContactTypeID INT OUTPUT | ||
) | ||
AS | ||
DECLARE @Err_Code AS INT; | ||
SELECT @Err_Code = 0; | ||
|
||
SELECT @ContactTypeID = ContactTypeID | ||
FROM Person.ContactType | ||
WHERE [Name] = @Name; | ||
|
||
IF @ContactTypeID IS NOT NULL | ||
RETURN; -- Exit 1: if the ContactType exists | ||
|
||
INSERT | ||
INTO Person.ContactType ([Name], ModifiedDate) | ||
SELECT @Name, CURRENT_TIMESTAMP; | ||
|
||
SELECT @Err_Code = @@error; | ||
IF @Err_Code <> 0 | ||
RETURN @Err_Code; -- Exit 2: if there is an error on INSERT | ||
|
||
SELECT @ContactTypeID = SCOPE_IDENTITY(); | ||
|
||
RETURN @Err_Code; -- Exit 3: after successful INSERT | ||
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,32 @@ | ||
-- Sample program Listing 1-8 from Chapter 1 | ||
|
||
USE AdventureWorks; | ||
GO | ||
IF OBJECT_ID('dbo.GetOrAdd_ContactType') IS NOT NULL | ||
DROP PROCEDURE dbo.GetOrAdd_ContactType; | ||
GO | ||
CREATE PROCEDURE dbo.GetOrAdd_ContactType | ||
( | ||
@Name NVARCHAR(50), | ||
@ContactTypeID INT OUTPUT | ||
) | ||
AS | ||
DECLARE @Err_Code AS INT; | ||
SELECT @Err_Code = 0; | ||
|
||
SELECT @ContactTypeID = ContactTypeID | ||
FROM Person.ContactType | ||
WHERE [Name] = @Name; | ||
|
||
IF @ContactTypeID IS NULL | ||
BEGIN | ||
INSERT | ||
INTO Person.ContactType ([Name], ModifiedDate) | ||
SELECT @Name, CURRENT_TIMESTAMP; | ||
|
||
SELECT @Err_Code = @@error; | ||
IF @Err_Code = 0 -- If there’s an error skip next | ||
SELECT @ContactTypeID = SCOPE_IDENTITY(); | ||
END | ||
RETURN @Err_Code; -- Single exit point | ||
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,11 @@ | ||
-- Sample program Listing 1-9 from Chapter 1 | ||
|
||
USE AdventureWorks; | ||
GO | ||
-- This query generates a very elaborate error message because it is using | ||
-- the deprecated *= join operator | ||
SELECT o.name | ||
FROM sys.objects o, | ||
sys.views v | ||
WHERE o.object_id *= v.object_id; | ||
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,20 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 9.00 | ||
# Visual Studio 2005 | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Listing1-1", "Listing1-1\Listing1-1.csproj", "{B0C40F2B-9C58-463D-B44B-5A86ABE2452B}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{B0C40F2B-9C58-463D-B44B-5A86ABE2452B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{B0C40F2B-9C58-463D-B44B-5A86ABE2452B}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{B0C40F2B-9C58-463D-B44B-5A86ABE2452B}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{B0C40F2B-9C58-463D-B44B-5A86ABE2452B}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
EndGlobal |
Binary file not shown.
50 changes: 50 additions & 0 deletions
50
Software/Chapter 1/cs/Listing1-1/Listing1-1/Listing1-1.csproj
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,50 @@ | ||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<PropertyGroup> | ||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | ||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | ||
<ProductVersion>8.0.50727</ProductVersion> | ||
<SchemaVersion>2.0</SchemaVersion> | ||
<ProjectGuid>{B0C40F2B-9C58-463D-B44B-5A86ABE2452B}</ProjectGuid> | ||
<OutputType>Exe</OutputType> | ||
<AppDesignerFolder>Properties</AppDesignerFolder> | ||
<RootNamespace>Listing1_1</RootNamespace> | ||
<AssemblyName>Listing1-1</AssemblyName> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> | ||
<DebugSymbols>true</DebugSymbols> | ||
<DebugType>full</DebugType> | ||
<Optimize>false</Optimize> | ||
<OutputPath>bin\Debug\</OutputPath> | ||
<DefineConstants>DEBUG;TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> | ||
<DebugType>pdbonly</DebugType> | ||
<Optimize>true</Optimize> | ||
<OutputPath>bin\Release\</OutputPath> | ||
<DefineConstants>TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Reference Include="System" /> | ||
<Reference Include="System.Data" /> | ||
<Reference Include="System.Xml" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Compile Include="Program.cs" /> | ||
<Compile Include="Properties\AssemblyInfo.cs" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Content Include="Person_Contact.txt" /> | ||
</ItemGroup> | ||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> | ||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. | ||
Other similar extension points exist, see Microsoft.Common.targets. | ||
<Target Name="BeforeBuild"> | ||
</Target> | ||
<Target Name="AfterBuild"> | ||
</Target> | ||
--> | ||
</Project> |
Oops, something went wrong.