Commit 873a23b8 authored by O'Reilly Media, Inc.'s avatar O'Reilly Media, Inc.

Initial commit

parents

Too many changes to show.

To preserve performance only 1000 of 1000+ files are displayed.

USE AdoDotNet35Cookbook
GO
CREATE TABLE AddressExpand(
AddressID int NOT NULL PRIMARY KEY,
AddressLine1 nvarchar(60) NOT NULL,
AddressLine2 nvarchar(60) NULL,
City nvarchar(30) NOT NULL,
StateProvinceName nvarchar(50) NOT NULL,
PostalCode nvarchar(15) NOT NULL,
CountryRegionName nvarchar(50) NOT NULL )
\ No newline at end of file
USE AdoDotNet35Cookbook
GO
CREATE TABLE ReadWriteLargeData(
Id int NOT NULL PRIMARY KEY,
NVarCharMaxField nvarchar(max) NULL,
VarBinaryMaxField varbinary(max) NULL,
VarCharMaxField varchar(max) NULL )
\ No newline at end of file
USE AdoDotNet35Cookbook
GO
CREATE ASSEMBLY ClrPointType
FROM '<path>\ClrPointType\bin\Debug\ClrPointType.dll'
GO
CREATE TYPE Point
EXTERNAL NAME ClrPointType
GO
CREATE TABLE PointTable(
Id int NOT NULL PRIMARY KEY,
PointField Point NOT NULL )
GO
\ No newline at end of file
CREATE TABLE "ADODOTNET35COOKBOOK"."READWRITELARGEDATA" (
"ID" INTEGER NOT NULL,
"BLOBFIELD" BLOB,
"CLOBFIELD" CLOB,
"NCLOBFIELD" NCLOB,
PRIMARY KEY ("ID") VALIDATE )
\ No newline at end of file
USE AdoDotNet35Cookbook
GO
CREATE TABLE BatchUpdateAuto(
Id int NOT NULL PRIMARY KEY,
Field1 nvarchar(50) NULL,
Field2 nvarchar(50) NULL )
GO
INSERT INTO BatchUpdateAuto VALUES (1, 'Field1.1', 'Field2.1');
INSERT INTO BatchUpdateAuto VALUES (2, 'Field1.2', 'Field2.2');
INSERT INTO BatchUpdateAuto VALUES (3, 'Field1.3', 'Field2.3');
GO
CREATE TABLE BatchUpdateManual(
Id int NOT NULL PRIMARY KEY,
Field1 nvarchar(50) NULL,
Field2 nvarchar(50) NULL )
GO
INSERT INTO BatchUpdateManual VALUES (1, 'Field1.1', 'Field2.1');
INSERT INTO BatchUpdateManual VALUES (2, 'Field1.2', 'Field2.2');
INSERT INTO BatchUpdateManual VALUES (3, 'Field1.3', 'Field2.3');
GO
\ No newline at end of file
USE AdoDotNet35Cookbook
GO
CREATE TABLE AutoRefresh(
Id int NOT NULL PRIMARY KEY,
Field1 nvarchar(50) NULL,
Field2 nvarchar(50) NULL )
GO
INSERT INTO AutoRefresh VALUES (1, 'Field1.1', 'Field2.1');
INSERT INTO AutoRefresh VALUES (2, 'Field1.2', 'Field2.2');
INSERT INTO AutoRefresh VALUES (3, 'Field1.3', 'Field2.3');
\ No newline at end of file
USE AdoDotNet35Cookbook
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE AutoRefreshChange(
Id int NOT NULL PRIMARY KEY,
Field1 nvarchar(50) NULL,
Field2 nvarchar(50) NULL )
GO
INSERT INTO AutoRefreshChange VALUES (1, 'Field1.1', 'Field2.1');
INSERT INTO AutoRefreshChange VALUES (2, 'Field1.2', 'Field2.2');
INSERT INTO AutoRefreshChange VALUES (3, 'Field1.3', 'Field2.3');
GO
ALTER DATABASE AdoDotNet35Cookbook SET ENABLE_BROKER
GO
SELECT DATABASEPROPERTYEX('AdoDotNet35Cookbook', 'IsBrokerEnabled')
\ No newline at end of file
USE AdventureWorks
GO
CREATE PROCEDURE Page_Contact
@PageCommand nvarchar(10),
@FirstContactID int = null,
@LastContactID int = null,
@PageCount int output,
@CurrentPage int output
AS
SET NOCOUNT ON
SELECT @PageCount = CEILING(COUNT(*)/10) FROM Person.Contact
-- first page is requested OR previous page when the current
-- page is already the first
IF @PageCommand = 'FIRST' OR (@PageCommand = 'PREVIOUS' AND @CurrentPage <= 1)
BEGIN
SELECT TOP 10 *
FROM Person.Contact
ORDER BY ContactID
SET @CurrentPage = 1
RETURN 0
END
-- last page is requested or next page when the current
-- page is already the last
IF @PageCommand = 'LAST' OR (@PageCommand = 'NEXT' AND @CurrentPage >= @PageCount)
BEGIN
SELECT a.*
FROM
(SELECT TOP 10 *
FROM Person.Contact
ORDER BY ContactID DESC) a
ORDER BY ContactID
SET @CurrentPage = @PageCount
RETURN 0
END
IF @PageCommand = 'NEXT'
BEGIN
SELECT TOP 10 *
FROM Person.Contact
WHERE ContactID > @LastContactID
ORDER BY ContactID
SET @CurrentPage = @CurrentPage+1
RETURN 0
END
IF @PageCommand = 'PREVIOUS'
BEGIN
SELECT a.*
FROM (
SELECT TOP 10 *
FROM Person.Contact
WHERE ContactID < @FirstContactID
ORDER BY ContactID DESC) a
ORDER BY ContactID
SET @CurrentPage = @CurrentPage-1
RETURN 0
END
IF @PageCommand = 'GOTO'
BEGIN
IF @CurrentPage < 1
SET @CurrentPage = 1
ELSE IF @CurrentPage > @PageCount
SET @CurrentPage = @PageCount
DECLARE @RowCount int
SET @RowCount = (@CurrentPage * 10)
EXEC ('SELECT * FROM
(SELECT TOP 10 a.* FROM
(SELECT TOP ' + @RowCount + ' * FROM Person.Contact ORDER BY ContactID) a
ORDER BY ContactID DESC) b
ORDER BY ContactID')
RETURN 0
END
RETURN 1
GO
\ No newline at end of file
USE AdoDotNet35Cookbook
GO
CREATE TABLE Customers(
CustomerID nvarchar(5) NOT NULL PRIMARY KEY,
CompanyName nvarchar(40) NULL,
ContactName nvarchar(30) NULL,
ContactTitle nvarchar(30) NULL,
Address nvarchar(60) NULL,
City nvarchar(15) NULL,