0

I need to get the definition of some objects in the SQL server. I got the definitions of stored procedures, functions, views and triggers from sys.sql_modules.

But, I don't know how to get that of user-defined table types and of sequences. I am trying to create this in another database and automate this process.

Does anyone know how to get the definition of table types and sequences?

1

1 Answer 1

0

Still working on the create script, huh? ;-). Below the meta data of the objects requested.

/*The configuration of the sequences*/
SELECT *
FROM sys.objects AS o
    JOIN sys.sequences AS s
        ON s.object_id = o.object_id
WHERE o.type = 'SO';

/*The columns of the table types*/
SELECT tt.name,
       c.*
FROM sys.table_types tt
    INNER JOIN sys.columns c
        ON c.object_id = tt.type_table_object_id
ORDER BY c.column_id;
3
  • Hi Peter , This only give the names of the types and sequences , what I needed was the definition . Thanks anyway . You guys are great 🙂 Commented Nov 25, 2022 at 12:13
  • The create script, is as far as I know not defined in a definition, but you can create it based on the columns in the s.* (sequences) and the c.* (table types).
    – Peter
    Commented Nov 25, 2022 at 12:31
  • Yeah! I have don it for table types.now working on sequences . Thank you🙂❤️ Commented Nov 25, 2022 at 14:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.