programming4us
programming4us
DATABASE

SQL Server 2008 : Using the CLR - CLR Integration

- How To Install Windows Server 2012 On VirtualBox
- How To Bypass Torrent Connection Blocking By Your ISP
- How To Install Actual Facebook App On Kindle Fire
As SQL Server became more widely used, database professionals and developers demanded the ability to incorporate advanced logic and functionality into their database objects. Transact-SQL remains the best language to perform set-based tasks as it was designed specifically for querying and manipulating large data sets efficiently. You should always choose Transact-SQL when querying data. As Transact-SQL is an immensely powerful query language, it is less well suited to complex operations. Consider how difficult it would be to implement the following tasks using Transact-SQL:
  • Validate whether a phone number is valid for a specific city and country

  • Store complex data types like GPS coordinates in a single column

  • Read data from the Windows registry

  • Split someone‚Äôs full name into first name, last name, and middle initials

  • Read a file from a network, and share and import its data and attributes

  • Write to a file in the file system

CLR integration in SQL Server allows you to implement these tasks using only a few lines of code. This extended functionality can then be accessed in the same way as standard SQL Server database objects and as part of Transact-SQL queries.

Implementing advanced functionality using the CLR has many advantages. First of all, .NET languages are fully featured programming languages and offer elements like arrays, looping through collections, and object-oriented programming, just to name a few. Transact-SQL, being a query-oriented language, does not support those elements. Additionally, the Base Class Library is available through CLR integration. Using the Base Class Library you can access rich functionality for text manipulation, file and registry access, cryptography, and much more. Using managed code you can also define and manipulate complex data types like localized dates and times, currencies, and spatial coordinates. Finally, because managed code is compiled to native code, it may sometimes offer performance advantages over Transact-SQL, which is interpreted at runtime.

Configuring & Implementing...: Enabling CLR Integration

In SQL Server 2008, CLR integration is disabled by default, and you must explicitly enable this feature before you can use it. Only those accounts that have ALTER SETTINGS permissions to the SQL Server server can enable and disable CLR integration. By default, only members of sysadmin and serveradmin server roles have this permission. To enable CLR integration in SQL Server, use the sp_configure stored procedure with the clr enabled parameter set to the value of 1, as shown in the following example:

sp_configure 'show advanced options', 1;
GO
RECONFIGURE;
GO
sp_configure 'clr enabled', 1;
GO
RECONFIGURE;
GO

The following output will be produced when the sp_configure succeeds:

Configuration option 'show advanced options' changed from 0 to 1. Run
the RECONFIGURE statement to install.

Configuration option 'clr enabled' changed from 0 to 1. Run the
RECONFIGURE statement to install.

To disable the CLR-integration feature, execute sp_configure with the clr enabled parameter set to 0. When you disable CLR integration, all CLR object code executing within SQL Server is immediately interrupted. This may lead to data consistency issues, cause unexpected errors, and negatively impact users of the system. Ensure that no current activity is interrupted when you disable the functionality.


Note that the .NET Framework is available in many versions. Managed code is compiled for a specific version of the .NET Framework and cannot be executed by a different version. For example, code compiled for .NET Framework 1.1 will not execute in .NET Framework 1.0 and vice versa. SQL Server 2008 supports .NET Framework 2.0 and later. You can use Visual Studio 2005 or Visual Studio 2008 to write code targeting .NET Framework 2.0, but you cannot use Visual Studio 2003 or earlier.

Other  
 
Top 10
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 2) - Wireframes,Legends
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 1) - Swimlanes
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Formatting and sizing lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Adding shapes to lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Sizing containers
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 3) - The Other Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 2) - The Data Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 1) - The Format Properties of a Control
- Microsoft Access 2010 : Form Properties and Why Should You Use Them - Working with the Properties Window
- Microsoft Visio 2013 : Using the Organization Chart Wizard with new data
REVIEW
- First look: Apple Watch

- 3 Tips for Maintaining Your Cell Phone Battery (part 1)

- 3 Tips for Maintaining Your Cell Phone Battery (part 2)
programming4us programming4us
Celebrity Style, Fashion Trends, Beauty and Makeup Tips.
programming4us
 
 
programming4us