SQL Server Performance

user-defined datatypes

Discussion in 'General DBA Questions' started by axlcrew, Feb 7, 2003.

  1. axlcrew New Member

    I was wondering why I can't use a user-defined datatype in the CAST() or CONVERT() functions, if anyone knows.
  2. satya Moderator

    By default UDFs cannot be used in CAST & CONVERT. Being UDFs are system based ones you have to use system data_types.

    Satya SKJ
  3. axlcrew New Member

    Maybe I'm getting my terminology mixed up...isn't UDF a function? I was talking about datatypes. For example, if I created a datatype called "typeDateString", such as:

    sp_addtype typeDateString, 'VARCHAR(11)', NOT NULL

    Why can't I use that in convert:

    CONVERT(typeDateString, GETDATE(), 101)

    Is there a way around this? Or am I just being lazy?
  4. satya Moderator

    Instead use VARCHAR directly in CONVERT function, by design User defined datatypes are not allowed.

    Satya SKJ

    --Apologies for mentioning UDFs read as user defined datatypes on previous post.

Share This Page