Forum Discussion
To get definition of different type of object using sqlcmd utility from Microsoft SQL Server 2019
to get definition of sql object of type: Table, Sequence, Queue, Default constraints, Check constraints, Primary key, unique key, Index.
Khushboo55 , surely you can query all object defenitions, but because all objets are different in structure you have to write different per each.
One way ist to use System Information Schema Views (Transact-SQL) - SQL Server | Microsoft Learn
- Khushboo55Mar 07, 2024Copper Contributor
olafhelper Thank you! I have tried Information schema view but that didn't work.
I am using different query for each object type.
For sql object of type : Stored Procedure, Function, Trigger and View, I am getting definition using sys.sql_modules catalog view.
For sql object of type: Default constraint, I am getting definition using sys.default_constraints catalog view.
For sql object of type: Check constraint, I am getting definition using using sys.check_constraints catalog view.
I need help to get definition of this objects:
Table, Sequence, Queue, Primary Key, Unique Key, Index. using command line query (I need exact definition I get from SSMS Generate script wizard gui to create a Transact-SQL script)
Appreciate your help!
- olafhelperMar 07, 2024Bronze ContributorSee the link I posted, you can query all informations from system views.