![]() If the date is in the future, don't allow it, change to missing Commented out for this project as future dates are OK If there's any data prior to 2000 it was incorrectly entered, mark it as missing IF Date IS NULL OR Date = '' OR Date = -1 If the date is missing, or a placeholder for a missing date, set to the Id for missing dates Create a helper function to convert dates to a YYYYMMDD format Date Id. PRINT 'Done Creating AdventureWorksDW2013R2' TO N 'C:\Program Files\Microsoft SQL Server\MSSQL10_50.SQL2008R2\MSSQL\DATA\AdventureWorksDW2013R2_log.ldf', TO N 'C:\Program Files\Microsoft SQL Server\MSSQL10_50.SQL2008R2\MSSQL\DATA\AdventureWorksDW2013R2_Data.mdf', ![]() RESTORE DATABASE įROM DISK = N 'C:\Program Files\Microsoft SQL Server\MSSQL10_50.SQL2008R2\MSSQL\Backup\AdventureWorksDW2008R2.bak' PRINT 'Restoring AdventureWorksDW2008R2 to AdventureWorksDW2013R2' ![]() PRINT 'Deleting AdventureWorksDW2013R2, if it exists'ĮXEC _delete_database_backuphistory = N 'AdventureWorksDW2013R2' Delete the database AdventureWorksDW2013 if it exists. NAME = N 'AdventureWorksDW2008R2-Full Database Backup', TO DISK = N 'C:\Program Files\Microsoft SQL Server\MSSQL10_50.SQL2008R2\MSSQL\Backup\AdventureWorksDW2008R2.bak' PRINT 'Backing up AdventureWorksDW2008R2' Make a backup of AdventureWorksDW2008R2. * Step 1 - Make a copy of AdventureWorksDW2008R2 and restore as AdventureWorksDW2013 */ PRINT 'Updating AdventureWorksDW2008R2 for Today - Starting' * Be warned, if AdventureWorksDW2013R2 exists, it will be deleted as part of this process. It won't change AdventureWorksDW2008R2 in anyway. This script is dependent on the AdventureWorks2008R2DW sample */ It will then update it for current dates. * This script will make a backup of the AdventureWorks2012DW database, then copy and restore it */ * AdventureWorks database Copyright (c) Microsoft. * Script Copyright (c) 2013 by Robert C. * Updating AdventureWorks2008R2 for Today */ Without further ado, here is the script for AdventureWorksDW2008R2, which will create a new AdventureWorksDW2013R2 database. The structure of the script is basically the same as the one in the first post, so I’ll let you refer back to it for the explanations. The file for the data warehouse is either “AdventureWorks 2008R2 DW Script”, which is a T-SQL script that creates and populates the 2008R2 data warehouse, or “AdventureWorksDW2008R2 Data File” which is a database file you’ll need to reattach. Note there are several versions of Adventure Works here. If you don’t have the AdventureWorksDW2008R2 data warehouse database, you can obtain it from or go to CodePlex and search for SQL Server 2008 Sample Databases. I did find some subtle differences between the 2008R versions of the Adventure Works Data Warehouse that I wanted to post an updated version of the script to use with 2008R2. My upcoming class is using SQL Server 2008R2, and as such I wanted to update the 2008R2 version of AdventureWorksDW. In that post I included a script that would take the AdventureWorksDW2012 sample database, available on CodePlex, and convert it to use current dates.Īs part of my job at PragmaticWorks I teach classes on SQL Server Analysis Services. ![]() Back in May I did a post called “ Updating AdventureWorksDW2012 for Today”. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |