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. ...

Get Programming Microsoft® ADO.NET 2.0 Core Reference, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.