Going further
Import on a schedule (cron)
A recurring job keeps the documentation current without anyone opening SSMS. Set it up once. See Import a schema first for the security notes.
Wrap the extractor as a stored procedure in your own database, so the job runs one line instead of piping the whole script. The demo workspace documents this flow — load the demo and open the ZestreaDB extraction flow to see what it looks like.
Under Admin → Automation Keys, create a key scoped to this workspace, and give it to the job as
ZESTREA_KEY.Grant the service account GRANT VIEW DEFINITION and GRANT SELECT ON sys.sql_expression_dependencies.
That is exactly reading object definitions and dependency metadata, nothing else — the sentence that gets the grant approved.
Run this on your schedule — pick your authentication and copy the whole command:
SQL login
SERVER=your-server.example.com,1433 DATABASE=YourDatabase SQLUSER=your-user SQLPASS=your-password ZESTREA_KEY=your-api-keysqlcmd -S "$SERVER" -U "$SQLUSER" -P "$SQLPASS" -C -d "$DATABASE" \ -Q "EXEC dbo.ZestreaDB_ExtractSchema" \ -h -1 -W -y 0 -o /tmp/schema.json \ && curl -X POST https://zestreadb.com/api/v1/ingest/schema \ -H "Authorization: Bearer $ZESTREA_KEY" \ -H "Content-Type: application/json" \ --data-binary @/tmp/schema.jsonWindows auth
SERVER=your-server.example.com,1433 DATABASE=YourDatabase ZESTREA_KEY=your-api-keysqlcmd -S "$SERVER" -E -C -d "$DATABASE" \ -Q "EXEC dbo.ZestreaDB_ExtractSchema" \ -h -1 -W -y 0 -o /tmp/schema.json \ && curl -X POST https://zestreadb.com/api/v1/ingest/schema \ -H "Authorization: Bearer $ZESTREA_KEY" \ -H "Content-Type: application/json" \ --data-binary @/tmp/schema.jsonEntra ID
SERVER=your-server.example.com,1433 DATABASE=YourDatabase ZESTREA_KEY=your-api-keysqlcmd -S "$SERVER" -G -C -d "$DATABASE" \ -Q "EXEC dbo.ZestreaDB_ExtractSchema" \ -h -1 -W -y 0 -o /tmp/schema.json \ && curl -X POST https://zestreadb.com/api/v1/ingest/schema \ -H "Authorization: Bearer $ZESTREA_KEY" \ -H "Content-Type: application/json" \ --data-binary @/tmp/schema.jsonThe
-h -1 -W -y 0flags stopsqlcmdformatting the output for a terminal.
Prefer not to grant those rights? An alternative is EXECUTE AS OWNER on the procedure, so the caller needs only EXECUTE — at the cost of the procedure running elevated, which some teams will not allow.