Microsoft SQL Server Time Series Sample - Personal Stock Planner

‘Personal Stock Planner’ is an excel-based application that leverages the functionalities provided by the Microsoft SQL Server Time Series Sample – Time Series Library. This is a simple two-tier application with a database tier and a presentation tier. The database consists of details of a hypothetical stock market and the ‘Time Series Library’ that is used by the presentation tier.  We recommend the users to get familiar with the Time Series Library before they start using PersonalStockPlanner.

 

Note:

When you compile common language runtime (CLR) integration samples, the path of the version of the Microsoft .NET Framework compiler that was distributed with SQL Server must be the first Framework directory in the PATH environment variable. The location of the compiler that is included with SQL Server is either drive:\WINNT\Microsoft.NET\Framework\v2.0.xxxxx or drive:\Windows\Microsoft.NET\Framework\v2.0.xxxxx, where drive is the installation drive and xxxxx is the version of the .NET Framework that is included with SQL Server.

 

The default installation directory is drive:\Program Files\Microsoft SQL Server\100\Samples\Engine\Programmability\CLR\TimeSeries\PersonalStockPlanner

 

Scenario

·          An analyst want to examine the historical stock market data to identify the trend represented by the sequence of observations and make some future prediction based on the data.

 

Languages

Visual C#.

 

Prerequisites

Before running this sample, make sure the following software is installed:

·         SQL Server 2005 (or later) or SQL Server 2005 (or later) Express Edition (SQL Server Express). You can obtain SQL Server Express free of charge from the SQL Server 2005 Express Edition Documentation and Samples Web site.

·         Microsoft Visual Studio 2005

·         Microsoft Visual Studio 2005 Tools for the Microsoft Office System

·         Microsoft Office Excel 2003 SP1 or SP2

 

Building the sample

To run ‘Personal Stock Planner’, a sample database, DemoDB, which hosts the data for a hypothetical stock market and the ‘Time Series Library’, should be present. Create the sample database on local instance of SQL Server 2005 or SQL Server 2005 Express Edition using the following instructions.

 

To create the sample database

 

1.       Open the <ApplicationFolder>\Scripts\EnableCLR.sql file in the SQL Server Management Studio. Run the script that is contained in the file, or run a command similar to the following at the command prompt:

 

sqlcmd -E -I -i <ApplicationFolder>\Scripts\EnableCLR.sql

This script enables SQL Server to execute common language runtime (CLR) code.

2.       Open the <ApplicationFolder>\Scripts\DemoDB.sql file in the SQL Server Management Studio. Run the script that is contained in the file, or run a command similar to the following at the command prompt:

 

sqlcmd -E -I -i <ApplicationFolder>\Scripts\DemoDB.sql

 

This script performs the following actions:

·         Creates the database DemoDB if it does not exist.

·         Creates Time Series metadata tables.

·         Registers the Time Series assemblies and creates the Time Series Library.

·         Creates the hypothetical stock market data tables and loads them with data.

 

To build the sample, do the following:

 

Build the sample

 

1.       Ensure that the sample database, DemoDB, is installed on local SQL Server or SQL Server Express instance.

2.       To run the sample successfully, you need to lower macro settings of excel application to medium level. Click on Start menu and select Run. Type ‘excel’ as the name of program to run and Click OK. Microsoft Office Excel 2003 opens up. Now Click Tools, point to Macro and click Security. In the Security Level tab, select ‘Medium’ and click OK.

3.       Compile the sample by using Visual Studio 2005 with Tools for Microsoft Office System installed and the provided Visual Studio solution, <ApplicationFolder>\PersonalStockPlanner\PersonalStockPlanner.sln, or by using Microsoft MSBuild, which is included in the .NET Framework SDK 2.0. Run a command similar to the following at the command prompt:

msbuild /nologo /verbosity:quiet /property:Configuration=Debug <ApplicationFolder>\PersonalStockPlanner\PersonalStockPlanner.sln

 

Running the sample

To run the sample, do the following:

 

Run the sample

1.       Open <ApplicationFolder>\PersonalStockPlanner\PersonalStockPlanner.sln in Visual Studio 2005 with Tools for the Microsoft Office System installed.

2.       Press F5 to run the application.

3.       Connect to the sample database, DemoDB, created previously when prompted to do so.

4.       The activated excel workbook allows a user to explore a database for prospective time series, create new calendars, time series instances and carry out time series analysis. Table ‘MarketDetail’ hosts the sample dataset with data gathered between 02-Jan-2002 and 25-Jan-2002.  Please refer to TimeSeries - User Documentation for the schema of sample dataset and detailed usage of the application.

 

Comments

The CLR for SQL Server 2005 (or later) or SQL Server 2005 (or later) Express Edition must be enabled for this sample to work correctly. Also ensure that Visual Studio Tools for the Microsoft Office System is installed on your machine.

 

Samples are provided for educational purposes only. They are not intended to be used in a production environment and have not been tested in a production environment. Microsoft does not provide technical support for these samples. Sample applications and assemblies should not be connected to or used with your production ssNoVersion database or your report server without the permission of the system administrator. 

 

© 2005 Microsoft Corporation. All rights reserved.