Конкатенация UDA
Imports System
Imports System.Data.Sql
Imports System.Data.SqlTypes
Imports System.Text
Imports System.IO

 _
 _
Public Class clr_Concat

    Private oConcatResult As StringBuilder

    Public Sub Init()
        oConcatResult = New StringBuilder()
    End Sub

    Public Sub Accumulate(ByVal value As SqlString)
        If value.IsNull Then
            Return
        End If

        oConcatResult.Append(value.Value).Append(«,»c)
    End Sub

    Public Sub Merge(ByVal value As clr_Concat)
        oConcatResult.Append(value.oConcatResult)
    End Sub

    Public Function Terminate() As SqlString
        If Not (oConcatResult Is Nothing) AndAlso oConcatResult.Length > 0 Then
            ? Remove the extra comma that we added.
            Return oConcatResult.ToString(0, oConcatResult.Length — 1)
        Else
            ? The value is null, so send back an empty string.
            Return New SqlString(«»)
        End If

    End Function
End Class