/*============================================================================
File: instawdb.sql
Summary: Creates the AdventureWorksDW sample database. Run this on
any version of SQL Server (2008R2 or later) to get AdventureWorksDW for your
current version.
Date: October 26, 2017
Updated: October 26, 2017
------------------------------------------------------------------------------
This file is part of the Microsoft SQL Server Code Samples.
Copyright (C) Microsoft Corporation. All rights reserved.
This source code is intended only as a supplement to Microsoft
Development Tools and/or on-line documentation. See these other
materials for detailed information regarding Microsoft code samples.
All data in this database is ficticious.
THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
PARTICULAR PURPOSE.
============================================================================*/
/*
* HOW TO RUN THIS SCRIPT:
*
* 1. Enable full-text search on your SQL Server instance.
*
* 2. Open the script inside SQL Server Management Studio and enable SQLCMD mode.
* This option is in the Query menu.
*
* 3. Copy this script and the install files to C:\Samples\AdventureWorksDW, or
* set the following environment variable to your own data path.
*/
:setvar SqlSamplesSourceDataPath "C:\Samples\AdventureWorksDW\"
/*
* 4. Append the SQL Server version number to database name if you want to
* differentiate it from other installs of AdventureWorksDW
*/
:setvar DatabaseName "AdventureWorksDW"
/* Execute the script
*/
IF '$(SqlSamplesSourceDataPath)' IS NULL OR '$(SqlSamplesSourceDataPath)' = ''
BEGIN
RAISERROR(N'The variable SqlSamplesSourceDataPath must be defined.', 16, 127) WITH NOWAIT
RETURN
END;
SET NOCOUNT OFF;
GO
PRINT CONVERT(varchar(1000), @@VERSION);
GO
PRINT '';
PRINT 'Started - ' + CONVERT(varchar, GETDATE(), 121);
GO
USE [master];
GO
-- ****************************************
-- Drop Database
-- ****************************************
PRINT '';
PRINT '*** Dropping Database';
GO
IF EXISTS (SELECT [name] FROM [master].[sys].[databases] WHERE [name] = N'$(DatabaseName)')
DROP DATABASE $(DatabaseName);
-- If the database has any other open connections close the network connection.
IF @@ERROR = 3702
RAISERROR('$(DatabaseName) database cannot be dropped because there are still other open connections', 127, 127) WITH NOWAIT, LOG;
GO
-- ****************************************
-- Create Database
-- ****************************************
PRINT '';
PRINT '*** Creating Database';
GO
CREATE DATABASE $(DatabaseName);
GO
PRINT '';
PRINT '*** Checking for $(DatabaseName) Database';
/* CHECK FOR DATABASE IF IT DOESN'T EXISTS, DO NOT RUN THE REST OF THE SCRIPT */
IF NOT EXISTS (SELECT TOP 1 1 FROM sys.databases WHERE name = N'$(DatabaseName)')
BEGIN
PRINT '*******************************************************************************************************************************************************************'
+char(10)+'********$(DatabaseName) Database does not exist. Make sure that the script is being run in SQLCMD mode and that the variables have been correctly set.*********'
+char(10)+'*******************************************************************************************************************************************************************';
SET NOEXEC ON;
END
GO
ALTER DATABASE $(DatabaseName)
SET RECOVERY SIMPLE,
ANSI_NULLS ON,
ANSI_PADDING ON,
ANSI_WARNINGS ON,
ARITHABORT ON,
CONCAT_NULL_YIELDS_NULL ON,
QUOTED_IDENTIFIER ON,
NUMERIC_ROUNDABORT OFF,
PAGE_VERIFY CHECKSUM,
ALLOW_SNAPSHOT_ISOLATION OFF;
GO
USE $(Datab�
没有合适的资源?快使用搜索试试~ 我知道了~
示例数据库 AdventureWorks安装脚本
共31个文件
csv:30个
sql:1个
需积分: 0 0 下载量 66 浏览量
2022-12-08
17:04:02
上传
评论
收藏 23.2MB ZIP 举报
温馨提示
内容摘要:除了通过备份文件来安装示例数据库 AdventureWorks 之外,我们还可以使用脚本来创建 AdventureWorks 数据库,而不必恢复数据库,无论什么版本都可以。 使用人群:学习或使用 SQL Server 的人 使用场景:SQL Server 实例,SQLCMD 使用目标:安装供学习使用的示例数据库
资源推荐
资源详情
资源评论
收起资源包目录
AdventureWorksDW-data-warehouse-install-script.zip (31个子文件)
DimProductCategory.csv 266B
DimDate.csv 694KB
FactInternetSalesReason.csv 1.61MB
FactSalesQuota.csv 16KB
DimReseller.csv 218KB
NewFactCurrencyRate.csv 4KB
ProspectiveBuyer.csv 700KB
DimSalesReason.csv 516B
DimEmployee.csv 17.7MB
DimOrganization.csv 806B
FactFinance.csv 3.99MB
DimDepartmentGroup.csv 360B
instawdbdw.sql 110KB
FactSurveyResponse.csv 347KB
DimScenario.csv 66B
DimSalesTerritory.csv 1.68MB
DatabaseLog.csv 321KB
FactCurrencyRate.csv 1.88MB
DimCurrency.csv 4KB
sysdiagrams.csv 701KB
FactResellerSales.csv 24.48MB
DimCustomer.csv 8.34MB
DimProductSubcategory.csv 3KB
DimProduct.csv 17.28MB
DimPromotion.csv 7KB
FactInternetSales.csv 20MB
FactProductInventory.csv 56.64MB
FactCallCenter.csv 20KB
DimGeography.csv 111KB
DimAccount.csv 11KB
FactAdditionalInternationalProductDescription.csv 3.69MB
共 31 条
- 1
资源评论
驾驭信息纵横科技
- 粉丝: 4582
- 资源: 1
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功