title: Can you create a CLR UDT to allow for a shared Table type across databases?
body: <p>If I had a SQL statement such as this:</p>
  
  <pre><code>CREATE TYPE [dbo].[typeRateLimitVariables] AS TABLE(
              [vchColumnName] [varchar](250) NULL,
              [decColumnValue] [decimal](25, 10) NULL
  )
  </code></pre>
  
  <p>And I used it as a table variable to a UDF in a database, I'd have sufficient scope. BUt let's say I wanted to call the scalar UDF from another database on the same server, then I'd end up with an unknown type error. </p>
  
  <p>I've tried creating the type on the calling DB, but obv. then I get a type mismatch because although each of the UDTs have the same name, they have different scopes and therefore are different types. </p>
  
  <p>I know you can create CLR types, register the assembly to SQL Server, and then access the custom type universally. </p>
  
  <p>My idea is to create a CLR UDT of type "TABLE", however I can't see how this can be implemented, as I know it must be of CLR type "SqlDbType.Structured"; </p>
  
  <p>My questions are: </p>
  
  <ol>
  <li>Is there a way without using the CLR to create global scope in SQL 2008 R2 for a table variable, and if not... </li>
  <li>How can I define a UDT in C# CLR, in which the UDT is essentially a UDT "AS TABLE"</li>
  </ol>