Skip to content

Add Principal to getledgerobjects.sql #43

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
sqlballs opened this issue Mar 15, 2023 · 1 comment
Closed

Add Principal to getledgerobjects.sql #43

sqlballs opened this issue Mar 15, 2023 · 1 comment

Comments

@sqlballs
Copy link
Member

In Module 4, Ledger Exercise, Exercise 3: Protecting Ledger tables from DDL changes

Issue: Attendee wanted to know who dropped the table in Exercise 3 (aka which login). The principal login for the user that dropped the table is not in the sys.ledger_table_history DMV.

getledgerobjects.sql queries sys.ledger_table_history and sys.ledger_column_history.

Fix:

add the follwing script which joins sys.ledger_table_history. with sys.database_ledger_transactions in order to get the principal_name column from the sys.database_ledger_transactions.
github screen shot 1

SELECT
t.[principal_name]
, t.[commit_time]
, h.[schema_name] + '.' + h.[table_name] AS [table_name]
, h.[ledger_view_schema_name] + '.' + h.[ledger_view_name] AS [view_name]
, h.[operation_type_desc]
FROM sys.ledger_table_history h
JOIN sys.database_ledger_transactions t
ON h.transaction_id = t.transaction_id

rgward added a commit that referenced this issue Mar 30, 2023
@rgward
Copy link
Member

rgward commented Mar 30, 2023

Great suggestion. Incorporated this into the Module exercises

@rgward rgward closed this as completed Apr 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants