Results 1 to 3 of 3

Thread: why user defined data type?

  1. #1
    Join Date
    Aug 2003
    Posts
    6

    why user defined data type?

    what are the advantages of using user-defined data types in SQL Server?

    for example,
    you may have Customer Number Cust_Num varchar(10)
    you can create a user-defined data type like this:
    udt_CustNum

    so now your table creation script for Custome table become:
    Cust_Num udt_CustNum

    however, once the user-defined data type is referred by other tables.
    it cannot be changed/deleted.

    So, i wonder what are the good reason of using udt instead of fundamental data types. (built-in datatypes)

    the only good thing i think is about:
    the abstract naming of the data type.
    you may have other key fields like Supplier Number which is varchar(12)
    instead of u have to remember varchar(10) for customer and varchar(12) for supplier
    u just to remember udt_CustNum for customer and udt_SuppNum for supplier.

    what do u think?

  2. #2
    Join Date
    Sep 2002
    Location
    Fantasy
    Posts
    4,254

  3. #3
    Join Date
    Aug 2003
    Posts
    6
    WOOT.
    very good article.
    thanks a lot MAK.

    The only real advantage to using user-defined data types is that they add the ability to self-document your data structures. For example, in several different tables you might have columns defined as varchar(30), and those columns might have nothing to do with each other. But if you define a data type called lastname to be equivalent to varchar(30), when you have multiple columns with the data type lastname, you know that those columns contain similar data.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •