O'Reilly logo

Programming Microsoft® ADO.NET 2.0 Core Reference, 2nd Edition by David Sceppa

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

SQL CLR Scenarios

Now let’s look at some examples of how you can use some of the features that are available through SQL CLR integration.

Creating a Scalar Function to Validate Data

What if you want to add a check constraint to perform complex validation on data coming into your database? You could build a scalar function, a function which returns a single value, such as a string or integer. For example, you could construct a scalar function to validate incoming postal code values based on the specified country and return a value to indicate whether the incoming value is valid. The goal is to accept values like 12345, 123456789, and 12345-6789 but not 1234567890 for United States addresses and to accept A1B-2C3 but not 1A2-B3C for Canadian addresses. ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required