Create SQL Server user defined table type based on a table
<p>I have a table in SQL Server. I want to bulk upload rows into this table using a user-defined table type (<a href="https://stackoverflow.com/questions/1030848/how-to-pass-user-defined-table-type-as-stored-procedured-parameter-in-c-sharp">example here</a>). To do this, I need to create a user-defined table type with the same format as my destination table. </p>

<p>Is there an easy way to do this, or do I have to copy all of the column information by hand?</p>

<p>In other words, I'm looking for the opposite of <a href="https://stackoverflow.com/questions/22390358/create-sql-server-table-based-on-a-user-defined-type">this question</a> (<em>create SQL Server table based on a user defined type</em>).  </p>

<p>I want to turn this:</p>

<pre><code>CREATE TABLE [dbo].[MyTable]
(
    AAA [int] NOT NULL,
    BBB [varchar](50) NOT NULL,
    CCC [datetime] NOT NULL
)
</code></pre>

<p>into this:</p>

<pre><code>CREATE TYPE [dbo].[udtMyTable] 
AS TABLE
   (
      AAA [int] NOT NULL,
      BBB [varchar](50) NOT NULL,
      CCC [datetime] NOT NULL
   )
</code></pre>

<p>Is it safe just to do a text-replace?</p>