Export (0) Print
Expand All
5 out of 5 rated this helpful - Rate this topic

Spatial Sample

SQL Server 2005

Updated: 5 December 2005

Microsoft SQL Server 2005 provides powerful indexing and query capabilities for basic types of data, such as integers, strings, and dates. However, existing indexing and query capabilities might be insufficient for large data sets containing complex data. The Spatial sample demonstrates how you can use common language runtime (CLR) integration technology in SQL Server 2005 to enhance the basic indexing and query capabilities to support more sophisticated types of data and queries over that data. Although the spatial sample is designed for supporting geospatial and celestial queries, the concepts behind the sample could be used for many other kinds of data.

This sample contains the following:

  1. An entire class library for representing and manipulating spatial information
  2. A sample database with spatial information
  3. Detailed documentation about the concepts behind the sample and the algorithms used.
  4. Installation and testing scripts

Install directory: drive:\Program Files\Microsoft SQL Server\90\Samples\Engine\Programmability\CLR\Spatial\

Jane is a developer for Adventure Works Cycles. She needs to represent, manipulate, and query spatial information.

Transact-SQL, Visual C#, and Visual Basic.

The Spatial sample uses the following features of Microsoft .

Application Area Features

Overall

CLR, table-valued functions, Transact-SQL

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

  • Microsoft SQL Server 2005 or Microsoft SQL Server 2005 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.
  • The SQL Server 2005 Database Engine samples. These samples are included with SQL Server 2005. You can download the latest version of the samples at the SQL Server Developer Web site.
  • .NET Framework SDK 2.0 or Microsoft Visual Studio 2005. You can obtain .NET Framework SDK free of charge. For more information, see Installing the .NET Framework SDK.

If you have not already created a strong name key file, generate the key file using the following instructions.

  1. Open a Microsoft Visual Studio 2005 command prompt. Click Start, point to All Programs, point to Microsoft .NET Framework SDK 2.0, and then click SDK Command Prompt.

    -- or --

    Open a Microsoft .NET Framework command prompt. Click Start, point to All Programs, point to Microsoft .NET Framework SDK 2.0, and then click SDK Command Prompt.

  2. Use the change directory command (CD) to change the current directory of the command prompt window to the folder where the samples are installed.
    ms345264.note(en-US,SQL.90).gifNote:
    To determine the folder where samples are located, click the Start button, point to All Programs, point to Microsoft SQL Server, point to Documentation and Tutorials, and then click Samples Directory. If the default installation location was used, the samples are located in <system_drive>:\Program Files\Microsoft SQL Server\100\Samples.
  3. At the command prompt, run the following command to generate the key file:

    sn -k SampleKey.snk

    ms345264.note(en-US,SQL.90).gifImportant:
    For more information about the strong-name key pair, see "Security Briefs: Strong Names and Security in the .NET Framework" in the .NET Development Center on MSDN.
  1. Compile the sample by using Visual Studio 2005 and the provided Visual Studio solution, or by using Microsoft MSBuild, which is included in the .NET Framework SDK 2.0. Run commands similar to the following at a .NET Framework command prompt:

    msbuild /nologo /verbosity:quiet /property:Configuration=Debug CS\Spatial.sln

  2. If you did not install the SQL Server Database Engine samples in the default location, modify the path in the CREATE ASSEMBLY part of the script in Scripts\spHtmCsharp.sql and the path to the database in the Scripts\AttachSpatialDatabase.bat file to refer to the location where the samples were installed.

  3. Attach the Spatial database by running the Scripts\AttachSpatialDatabase.bat file in a command prompt window.

  4. If you are not an administrator for the SQL Server instance you are using, you must have an administrator grant you CreateAssembly permission to complete the installation.

  5. Open the scripts\spHtmCsharp.sql in SQL Server Management Studio. Run the script contained in the file, or run a command similar to the following in a command prompt window:

    sqlcmd -E -I -i Scripts\spHtmCsharp.sql

  1. Open the Scripts\TestScript.sql file in Management Studio. Run the script that is contained in the file, or run a command similar to the following in a command prompt window:

    sqlcmd -E -I -i Scripts\TestScript.sql

The CLR for SQL Server 2005 or SQL Server Express must be enabled for this sample to work correctly.

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 SQL Server database or your report server without the permission of the system administrator.

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.