Automatically generate a user defined table type that matches an existing table

后端 未结 3 1254
清酒与你
清酒与你 2021-02-14 01:04

I have several tables that already exist in my database. Some of them have quite a few columns.

I want to make some stored procedures to do a merge statement with these

3条回答
  •  谎友^
    谎友^ (楼主)
    2021-02-14 01:37

    I never knew there was a wizard for generating database scripts like the one Dems is talking about in their answer. And it seems a more universal method than the one I've been using, because the wizard allows you to generate scripts for different types of objects in one go.

    Still, I guess I'll share mine, as it seems to me a little bit simpler and comes quite in handy when you only need to script same-type objects, like only tables.

    So, here goes (specifically for tables):

    1. Open Object Explorer (F8) and connect it to the target server instance.

    2. Expand the Databases item.

    3. Expand the item with your database name.

    4. Click Tables.

    5. Open Object Explorer Details (F7). It should now display the list of user tables.

    6. Using standard Windows methods of selecting multiple objects (like Ctrl+click), select the tables you want to script.

    7. Right-click on any of the selected items and choose Script Table as ▸, then pick the kind of script and where to save it.

    When you need to script different types of objects, proceed to a different Object Explorer ‘folder’ instead of Tables, e.g. for stored procedures it would be Programmability\Stored Procedures.

提交回复
热议问题