Skip to content

How can I automatically expose all the tables in my database? #1705

Answered by yorek
yorek asked this question in Q&A
Discussion options

You must be logged in to vote

There is no automation for automatically taking all tables (or views or stored procedures) from a database and automatically at them to the DAB configuration file. If you're using Azure SQL or SQL Server, you can generate the entities section of the configuration file using the following sample T-SQL (works on SQL Server 2022 or Azure SQL only as it uses the new JSON_OBJECT and JSON_ARRAY functions)

/*
    Table to publish as API
*/
drop table if exists #t;
select         
    [name] as entity_name,
    [name] as table_name,
    object_id,
    schema_id
into
    #t
from 
    sys.tables where [name] not in ('AdventureWorksDWBuildVersion', 'DatabaseLog', 'NewFactCurrencyRate')
;
-- select *…

Replies: 3 comments

Comment options

yorek
Sep 11, 2023
Maintainer Author

You must be logged in to vote
0 replies
Answer selected by yorek
Comment options

yorek
Sep 11, 2023
Maintainer Author

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants