��然"When Should I Use SQL-Server CLR User Definied Types 
(UDT)?"<http://weblogs.asp.net/alex_papadimoulis/archive/2005/10/20/428014.as
px>��篇�������到�����的观点:
Fortunately, with SQL Server's CLR UDTs, knowing when to use them is pretty 
clear: 
Never. 
���貌�说����������当������通���锥�����细�����煽����约����模�然����������
�������约����卸希����玫��粘��帽���豫������突���case����氐����,�����芯���
��要�芯��摹�����
�����case��������������搞懂��������歉�什么�摹�

��前�霉�一��UDT����������T-SQL弄�模�SSIS����������菘�时�����模���������也��
�嵌��������为month实�驶���int��type��CLR UDT����CLR��式��UDT������为什么要UD
T��������然��SQL Server�源���薹����������恕�UDT���园���元�兀�element����
�卸�����为��behavior��������然���芏�����倩�影��些���堋���要�����������;
1. Date, time, currency, and extended numeric types
2. Geospatial applications����������������spatial���偷�case����为��UDT���圆�
������linq����然�懈��枪俜���workaround��
3. Encoded or encrypted data

一��使��CLR UDT�牟������拢�
1. ��������UDT��assembly
2. 注��assembly
3. ��SQL Server�写���UDT
4. ����使��UDT�谋?�����筒���

msdn���懈�������:ms-help://MS.SQLCC.v10/MS.SQLSVR.v10.en/s10de_2devguide/h
tml/0feb8b08-4062-467b-8433-e88e4e302738.htm�����戮��谴���一�����泻�������
�������汀�

一����说�萍���UDT����为一���构�,����也���源���为一���。
UDT�����������碌�要��
1. UDT����指��Microsoft.SqlServer.Server.SqlUserDefinedTypeAttribute���萍�使
��System.SerializableAttribute
����
[Serializable]
[Microsoft.SqlServer.Server.SqlUserDefinedType(Format.Native,
     IsByteOrdered=true, ValidationMethodName = "ValidatePoint")]
���枚��谢�������UserDefined Serialization��Serialization Attributes��
2. ���构���斜����� System.Data.SqlTypes.INullable �涌冢���为SQL Server默��
��null-aware�模�
����
private bool is_Null;

public bool IsNull
{
    get
    {
        return (is_Null);
    }
}

public static Point Null
{
    get
    {
        Point pt = new Point();
        pt.is_Null = true;
        return pt;
    }
}
.....

�����泻芏�requirements������写�恕�����

一����说Microsoft.SqlServer.Server ��System.Data.SqlTypes ������namespace也��
通��要�拥摹�
����细����么��写���圆慰���Coding User-Defined Types ��<ms-help://MS.SQLCC.v10
/MS.SQLSVR.v10.en/s10de_2devguide/html/1e5b43b3-4971-45ee-a591-3f535e2ac722.h
tm>

注��assembly������UI也������T-SQL������UDT��CREATE TYPE
注��UDT���芸�Database������每����库都要����assembly��
����使��UDT����乇��使����通����没啥���
CREATE TABLE dbo.Points 
(ID int IDENTITY(1,1) PRIMARY KEY, PointValue Point)
����值��要convert��cast一�拢�
INSERT INTO dbo.Points (PointValue) VALUES (CONVERT(Point, '3,4'));
��询���要��示�幕���要转��一�拢�
SELECT ID, PointValue.ToString() AS PointValue 
FROM dbo.Points;

��ADO.NET�蟹���UDT�������������址�����
1. ��System.Data.SqlClient.SqlDataReader ��为object
2. ��SqlDataReader��为raw bytes
3. ��System.Data.SqlClient.SqlParameter ��为����
Update������DataAdapters 

�冒桑�case������������������report�恕�������毛���址��恕������������������� 
--
Welcome to Database Board
��迎������菘��
http://bbs.sjtu.edu.cn/bbsdoc?board=database

�� ��源:����水思源 bbs.sjtu.edu.cn��[FROM: 207.46.55.30]