User Id :    Password :      New Member   Forgot Password  
Topic: What are user defined datatypes and when you should go for them
Sachin Jain
30 Oct 2010 at 02:31 AM
What are user defined datatypes and when you should go for them?

Re: What are user defined datatypes and when you should go for them
Gaurav
31 Oct 2010 at 10:57 PM

User defined datatypes let you extend the base SQL Server datatypes by providing a descriptive name, and format to the database. Let's take a look how this works by adding a couple of User-Defined Data Types. we will add a birthday type which will be a datetime (on SQL Server 2008 it should be a date) and a StateCode which is a char(2)

  1. USE master
  2. EXEC SP_ADDTYPE birthday, DATETIME, 'NULL'
  3. Go
  4. EXEC SP_ADDTYPE StateCode,'Char(2)' , 'NULL'
  5. Go

Now we can create a table which uses these two types

  1. CREATE TABLE TestType (Birthday birthday,STATE StateCode)
Total Replies: 1
 
Featured Text Ad

Featured Ad