Sunday, April 22, 2007

AdventureWorksLT Sample Database Available For Download, Don't Forget To Attach The DB To See It

There is a new sample database available for SQL Server 2005. The name of this database is AdventureWorksLT , this database is a stripped down version of AdventureWorks.
You can download the installers for the AdventureWorksLT sample databases here
x86 AdventureWorksLT.msi -- 2,251 KB
x64 AdventureWorksLT_x64.msi -- 2,251 KB
Itanium (IA64) AdventureWorksLT_IA64.msi -- 2,251 KB

If you want to read more on the download page go here: http://www.microsoft.com/downloads/details.aspx?familyid=e719ecf7-9f46-4312-af89-6ad8702e4e6e&displaylang=en


Okay so you have downloaded the file and installed the database. But where is the database? You will have to attach the DB, you can use the wizard or this script below (make sure that you change the path and username, both are in bold font)

USE [master]
GO
CREATE DATABASE [AdventureWorksLT] ON
( FILENAME = N'C:\YourPathHere\MSSQL\Data\AdventureWorksLT_Data.mdf' ),
( FILENAME = N'C:\YourPathHere\MSSQL\Data\AdventureWorksLT_Log.ldf' )
FOR ATTACH
GO

if exists (select name from master.sys.databases sd where name = N'AdventureWorksLT' and SUSER_SNAME(sd.owner_sid) = SUSER_SNAME() )
EXEC [AdventureWorksLT].dbo.sp_changedbowner @loginame=N'LoginName', @map=false
GO


Now you can run these scripts to see how many tables, views, procedures and functions there are

SELECT TABLE_SCHEMA + '.' + TABLE_NAME AS FullTableName
FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_TYPE = 'BASE TABLE'
ORDER BY FullTableName

-------------------------
dbo.BuildVersion
dbo.ErrorLog
SalesLT.Address
SalesLT.Customer
SalesLT.CustomerAddress
SalesLT.Product
SalesLT.ProductCategory
SalesLT.ProductDescription
SalesLT.ProductModel
SalesLT.ProductModelProductDescription
SalesLT.SalesOrderDetail
SalesLT.SalesOrderHeader



SELECT TABLE_SCHEMA + '.' + TABLE_NAME AS FullTableName
FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_TYPE = 'VIEW'
ORDER BY FullTableName

-------------------------------------
SalesLT.vGetAllCategories
SalesLT.vProductAndDescription
SalesLT.vProductModelCatalogDescription


SELECT ROUTINE_NAME
FROM INFORMATION_SCHEMA.ROUTINES
WHERE ROUTINE_TYPE ='FUNCTION'

-------------------------
ufnGetCustomerInformation
ufnGetSalesOrderStatusText
ufnGetAllCategories


SELECT ROUTINE_NAME
FROM INFORMATION_SCHEMA.ROUTINES
WHERE ROUTINE_TYPE ='PROCEDURE'

-------------------------
uspPrintError
uspLogError

No comments: