You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+68-40Lines changed: 68 additions & 40 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,62 +1,95 @@
1
-
# SQLServer Data Lineage for T-SQL Queries
1
+
# Data Lineage for Microsoft SQL Server T-SQL Queries
2
2
3
3
Data Lineage Transact SQL (T-SQL) for [Microsoft SQL Server](https://www.microsoft.com/en-us/sql-server) enables you to find the data origins and data destinations in your query. It gives you the visibility over query data columns and ability to track the changes over time.
4
4
5
-
## Cloning the repository
6
-
You can follow the steps below to clone the repository.
Run **Remove_comments.sql** to create a procedure.
22
+
Strip and remove all comments from your T-SQL query by using _dbo.remove_comments_ procedure
17
23
18
-
1. Run the support files
24
+
```sql
25
+
-- Run procedure dbo.remove_comments
19
26
20
-
Run **helper_fun.sql** helper file, that will create a sample data tables and example procedure.
21
-
In addition, run a **remove_comments.sql** file to create a procedure with stripping and removing all the comments from your T-SQL query.
27
+
EXEC dbo.remove_comments
28
+
@procedure_name = N'dbo.MySample_procedure'
22
29
23
-
2. Removing comments from T-SQL Query
30
+
```
24
31
25
-
Strip and remove all comments from your T-SQL query by using _dbo.remove_comments_ procedure.
26
32
27
-
```sql
28
-
# Run procedure dbo.remove_comments
33
+
# Start with Data Lineage on T-SQL
34
+
35
+
Run **TSQL_data_lineage.sql** file to create a lineage procedure. This script includes the removal of comments and special characters and creates the data lineage.
29
36
30
-
EXEC dbo.remove_comments
31
-
@procedure_name = N'sql_sample_procedure'
32
37
38
+
```sql
39
+
-- Get your query:
40
+
declare @test_query VARCHAR(8000) ='
41
+
42
+
SELECT
43
+
s.[BusinessEntityID]
44
+
,p.[Title]
45
+
,p.[FirstName]
46
+
,p.[MiddleName]
47
+
,p.[LastName]
48
+
,p.[Suffix]
49
+
,e.[JobTitle] as imeSluzbe
50
+
,p.[EmailPromotion]
51
+
,s.[SalesQuota]
52
+
,s.[SalesYTD]
53
+
,s.[SalesLastYear]
54
+
,( SELECT GETDATE() ) AS DateNow
55
+
,( select count(*) FROM [AdventureWorks2014].sales.[SalesPerson] ) as totalSales
56
+
57
+
FROM [AdventureWorks2014].sales.[SalesPerson] s
58
+
LEFT JOIN [AdventureWorks2014].[HumanResources].[Employee] e
59
+
ON e.[BusinessEntityID] = s.[BusinessEntityID]
60
+
INNER JOIN [AdventureWorks2014].[Person].[Person] AS p
61
+
ON p.[BusinessEntityID] = s.[BusinessEntityID]
62
+
63
+
'
64
+
65
+
-- And run the procedure with single input parameter
66
+
EXEC dbo.TSQL_data_lineage
67
+
@InputQuery = @test_query
33
68
```
34
69
70
+
# Requirements
35
71
36
-
# Quickstart for Data Lineage on T-SQL
72
+
The script works with any of the following versions:
37
73
38
-
1. Clone the repository
39
-
2. Have your T-SQL query ready
40
-
3. Load the DataLineage table function with your query
74
+
* Microsoft SQL Server database (works on all editions and versions 2016+)
75
+
* Azure SQL Database
76
+
* Azure SQL Server
77
+
* Azure SQL MI
41
78
42
79
43
-
```sql
44
-
# Run
45
-
DECLARE @t_sql_query NVARCHAR(MAX)
46
-
SET @t_sql_query = N'-- Query
47
-
SELECT top 10
48
-
[name]
49
-
,object_id
50
-
--,principal_id
51
-
--,schema_did
52
-
,schema_id
53
-
from sys.tables'
54
-
55
-
56
-
SELECTdbo.fn_datalineage(@t_sql_query)
80
+
81
+
Get started
82
+
===========
83
+
The easiest way to get started is with fork or clone the repository.
84
+
85
+
86
+
## Cloning the repository
87
+
You can follow the steps below to clone the repository.
0 commit comments