title: How can I get user defined types definition in SQL Server 2008 R2 using SQL query?
body: <p>I have created a sample java program in which I get the definition of all objects like views, triggers, functions, etc. using the following queries:</p>
  
  <pre><code>select object_definition(object_id) 
  from sys.objects 
  where type = 'V'; //for Views
  
  select object_definition(object_id) 
  from sys.objects 
  where type = 'TF'; //for Functions
  
  select object_definition(object_id) 
  from sys.objects 
  where type = 'TR'; //for triggers
  </code></pre>
  
  <p>But <code>sys.objects</code> doesn't contain the user-defined data types and user-defined table types. I am using the following query to get user-defined types:-</p>
  
  <pre><code>select * 
  from sys.types 
  where is_user_defined = 1;
  </code></pre>
  
  <p>Is there any sql query using which I can get the definition for user-defined data types and user-defined table types?</p>