Readme_Hello World Ready 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.
The Hello World Ready sample demonstrates the basic operations that are involved in creating, deploying, and testing a simple world ready common language runtime (CLR) integration-based stored procedure. A world-ready component can be easily localized into
different languages for different markets around the world without changing the component's source code. This sample also demonstrates how to return data through an output parameter and through a record, which is dynamically constructed by the stored procedure
and returned to the client.
This sample is almost identical to the
Hello World Sample
except that it is much easier and safer to localize this application. To change localized text requires the following:
- Changing an XML file (the .resx file) for the particular culture in the resources directory
- Building the culture's resources file by using resgen
- Building the updated satellite DLL for that culture
Dropping and adding that assembly in SQL Server. The source code and assembly for the CLR stored procedure itself does not change. A build.cmd script is provided in the resources directory which demonstrates how to compile and link the resource assemblies.
Although the source code for the application creates a resource manager based the currently executing assembly, you do not have to embed the culture neutral resources in the DLL that contains the stored procedure. The
attribute that is used in the AssemblyInfo.cs or AssemblyInfo.vb file permits the culture-neutral resources to exist in a satellite DLL. It is much better to use a separate DLL for
this purpose so that when localized text needs to be added or changed, the primary DLL that contains the CLR stored procedure does not have to be changed. This is especially useful for CLR user-defined types that might have columns and other dependencies which
would make it difficult to drop and re-add the type.
Ordinarily, the satellite DLL versions must be identical to the main assembly version. However, you can use the
attribute to allow the main assembly to be updated without updating the satellite assemblies too. For more information, see the ResourceManager class in the Microsoft .NET Framework version 2.0 SDK
Install directory: C:\Program Files\Microsoft SQL Server\100\Samples\Engine\Programmability\CLR\HelloWorldReady\
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 understand the basics in using CLR integration stored procedures. She also has to understand how to make her CLR integration stored procedures world ready using resources which is the technique her
Transact-SQL, Visual C# and Visual Basic.
The Hello World Ready sample uses the following features of SQL Server.
Before running this sample, make sure the following software is installed:
- Microsoft SQL Server or Microsoft SQL Server Express. You can obtain SQL Server Express free of charge from the SQL Server Express Documentation and Samples
- The AdventureWorks database that is available at the SQL Server Developer
- The SQL Server Database Engine samples that are available at the SQL Server Developer
- .NET Framework SDK 2.0 or Microsoft Visual Studio 2005. You can obtain .NET Framework SDK free of charge. 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 Hello World Ready sample
- 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 an SDK command prompt:
msbuild /nologo /verbosity:quiet /property:Configuration=Debug CS\HelloWorld.sln
- Compile the satellite assemblies by executing the provided build.cmd file in the resources directory at a .NET Framework or Visual Studio command prompt. This file invokes resgen, which is included in Visual Studio or the .NET Framework SDK.
- Make sure that 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 section 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 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 Microsoft 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 Scripts\InstallCS.sql
Running the Sample
To run the Hello World Ready 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 at the command prompt:
sqlcmd -E -I -i Scripts\test.sql
Removing the Sample
To remove the Hello World Ready sample
- Open the scripts\cleanup.sql file in Management Studio and run the script that is contained in the file. Or, run the following command at the command prompt:
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_Hello World Sample
Readme_Calendar-Aware Date/Time UDT Sample
CREATE ASSEMBLY (Transact-SQL) DROP ASSEMBLY (Transact-SQL) CREATE PROCEDURE (Transact-SQL)
DROP PROCEDURE (Transact-SQL)
Help and Information
- Getting SQL Server 2008 Assistance* © 2008 Microsoft Corporation. All rights reserved.