Search code examples
sql-serveruser-defined-types

Copying user-defined types from one database to another


I am charged with creating an export from several tables in one database to a identically configured tables in another database, so first I have to create the identical configuration in the second database.

The problem is, when the first database was set up, they used what seems like hundreds of user defined types. I am not the greatest typist in the world and recreating these on the second database is going to a nightmare.

These user-defined types must be stored someplace, but I can't find them. I am thinking if I found the location where these types are stored, I could copy them to the second database and avoid trying to fat-finger though a couple hundred user-defined types.

Can anyone tell me where these types are stored, or of there is another way to solve my problem?

Thank you.


Solution

  • Right click on the database in SQL Server Management Studio, choose Tasks > Generate Scripts.... Then check user defined data types and table types. Click Next etc up until Finish.

    Once you have the script generated, execute it on the database you want to create the types in.

    enter image description here