Readme_Calendar-Aware Date/Time UDT Sample
This sample works only with SQL Server 2005 and SQL Server 2008. It will not work with any version of SQL Server earlier than SQL Server 2005.
Storing dates as strings can be confusing because dates are meaningless without understanding what calendar system is being used.
The CADatetime sample defines two user-defined data types, CADatetime and CADate, which provide calendar-aware handling of dates and times.
C:\Program Files\Microsoft SQL Server\100\Samples\Engine\Programmability\
SQL Server samples and sample databases must be downloaded and installed before you can view or work with them. For more information, see Considerations for Installing SQL Server Samples and Sample Databases
Jane is a developer for Adventure Works Cycles. She has to write software that processes dates and times from around the world. She uses the CADatetime and CADate UDTs to help express dates in a particular calendar system.
Transact-SQL, Visual C# and Visual Basic.
The CADatetime sample uses the following features of Microsoft SQL Server.
| Application Area || Features |
| UDT Implementation|| CLR |
| World-ready|| Satellite assemblies |
Before running this sample, make sure the following software is installed:
- SQL Server or SQL Server Express. You can obtain SQL Server Express free of charge from the SQL Server Express Documentation and Samples Web site
- The AdventureWorks database that is available at the SQL Server Developer Web site.
- The SQL Server Database Engine samples that are available 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 Documentation.
Building the Sample
If you have not already created a strong name key file, generate the key file using the following instructions.
To generate a strong name key file
- 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.
- Use the change directory command (CD) to change the current directory of the command prompt window to the folder where the samples are installed. Note: 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.*
- At the command prompt, run the following command to generate the key file: sn -k SampleKey.snk Important: 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.
To build the CADatetime sample
- Build the resource files for the sample by running the following commands in either an SDK command prompt window or a Visual Studio command prompt window: cd CS\CADateTime\resources build.cmd cd ..\..\..
- 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 a command similar to the following at a command prompt: msbuild /nologo /verbosity:quiet /property:Configuration=Debug CS\CADateTime.sln
- Make sure the AdventureWorks database is installed.
- 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\InstallCS.sql and Scripts\InstallVB.sql to refer to the location where the samples were installed.
- If you are not an administrator for the SQL Server instance you are using, you must have an administrator grant you CreateAssembly permission in order to complete the installation.
- Open the scripts\installCS.sql or scripts\installVB.sql file, depending on whether you compiled the Visual C# project or the Visual Basic project, 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\InstallCS.sql
Running the Sample
To run the CADatetime sample
- Open the scripts\test.sql file in Management Studio and run the script that is contained in the file. Or, run the following command in a command prompt window: sqlcmd -E -I -i Scripts\test.sql
Removing the Sample
To remove the CADatetime sample
- Open the scripts\cleanup.sql file in SQL Server Management Studio and run the script that is contained in the file. Or, run the following command in a command prompt window: sqlcmd -E -I -i Scripts\cleanup.sql
The CLR for SQL Server 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.
Readme_AdventureWorks Cycles CLR Layer Sample
Help and Information
- Getting SQL Server 2008 Assistance* © 2008 Microsoft Corporation. All rights reserved.