/************************************ Chapter 6 Scripts For MCITP SQL Server 2005 Database Administration All-in-One Exam Guide By Darril Gibson The scripts available here are the same ones used in each of the chapters. Ideally, you would type in the script and learn from any errors you might make. Occasionally, however, you may want a copy of the script to paste into the query window or into a batch file. If so, feel free to use these script files. I strongly encourage you not to rely on these pre-typed scripts, but instead to get used to typing the T-SQL yourself. The more you do it (even if you’re just typing what you see in the book), the more comfortable you’ll get with T-SQL. Some scripts in the book are intended to be run from the command line. They've been included where appropriate so that you can copy and paste them into Notepad and save them as a batch file (.bat). You can then run the batch file from the command prompt. *************************************/ sp_configure 'show advanced options', 1; RECONFIGURE; GO sp_configure 'affinity mask', 0; RECONFIGURE; GO /************************************/ USE Master; GO CREATE DATABASE Chapter6; GO USE Chapter6; CREATE TABLE dbo.TestTransactions ( TestTransactionsID int IDENTITY(1,1) NOT NULL, UserName varchar(50) NOT NULL, UserDate datetime NULL, CONSTRAINT [PK_AuditAccess_AuditAccessID] PRIMARY KEY CLUSTERED ( TestTransactionsID ) ); /************************************/ ALTER DATABASE Chapter6 SET RECOVERY FULL, PAGE_VERIFY CHECKSUM; GO /************************************/ DECLARE @intCounter int DECLARE @myDate datetime SET @intCounter = 1 WHILE @intCounter < 1000 BEGIN SET @myDate = DATEADD(day, 1, GetDate()) INSERT INTO TestTransactions VALUES(SUSER_SNAME(),@myDate); SET @intCounter = @intCounter + 1 END /************************************/ USE Master; GO EXEC sp_addlinkedserver 'MCITP2', 'SQL Server' GO /************************************/ -- Depends on Northwind Access database being in path SELECT CustomerID, CompanyName FROM OPENROWSET('Microsoft.Jet.OLEDB.4.0', 'C:\Program Files\Microsoft Office\OFFICE11\SAMPLES\Northwind.mdb'; 'admin';'',Customers) GO /************************************/ SELECT * FROM MCITP2.AdventureWorks.Sales.SalesOrderHeader