Giter Site home page Giter Site logo

tomaztk / sqlserver-data-lineage Goto Github PK

View Code? Open in Web Editor NEW
17.0 4.0 7.0 89 KB

Data Lineage for Microsoft SQL Server, Azure SQL Server and Azure Synapse

License: MIT License

TSQL 100.00%
data-lineage microsoft-sql-server t-sql sql sql-server sql-server-database remove remove-comments azure-sql-database azure-synapse

sqlserver-data-lineage's Introduction

Data Lineage for Microsoft T-SQL Queries

Data Lineage Transact SQL (T-SQL) for Microsoft SQL Server or Azure 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.

Features

  • Remove any kind of comments from your T-SQL code
  • Remove any special characters from your T-SQL code
  • Generate data lineage from your T-SQL Code
  • Learn interesting facts about your data and get better analytics

Removing comments from your T-SQL code

Clean your code of in-line and multiple lines of --comments or slash star comments from better visibility and greater readability.

Run Remove_comments.sql to create a procedure. Strip and remove all comments from your T-SQL query by using dbo.remove_comments procedure

--  Run procedure dbo.remove_comments

EXEC dbo.remove_comments
   @procedure_name = N'dbo.MySample_procedure'

Start with Data Lineage on T-SQL

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.

-- Get your query:
DECLARE @test_query VARCHAR(MAX) = '

-- This is a sample query to test data lineage
SELECT 
    s.[BusinessEntityID]
    ,p.[Title]
    ,p.[FirstName]
    ,p.[MiddleName]
   -- ,p.[LastName]
    ,p.[Suffix]
    ,e.[JobTitle] as JobName
    ,p.[EmailPromotion]
    ,s.[SalesQuota]
    ,s.[SalesYTD]
    ,s.[SalesLastYear]
	,( SELECT GETDATE() ) AS DateNow
	,( select count(*)  FROM [AdventureWorks2014].sales.[SalesPerson] ) as totalSales

/*

Adding some comments!

*/

FROM [AdventureWorks2014].sales.[SalesPerson] s
    LEFT JOIN [AdventureWorks2014].[HumanResources].[Employee] e 
    ON e.[BusinessEntityID] = s.[BusinessEntityID]
	INNER JOIN [AdventureWorks2014].[Person].[Person] AS p
	ON p.[BusinessEntityID] = s.[BusinessEntityID]

'

-- And run the procedure with single input parameter
EXEC dbo.TSQL_data_lineage 
  @InputQuery = @test_query

Requirements

The script works with any of the following versions:

  • Microsoft SQL Server database (works on all editions and versions 2016+)
  • Azure SQL Database
  • Azure SQL Server
  • Azure SQL MI

Get started

The easiest way to get started is with fork or clone the repository.

Cloning the repository

You can follow the steps below to clone the repository.

git clone https://github.com/tomaztk/SQLServer-Data-Lineage.git

Read more on blog posts

Remove comments from your T-SQL code (Blog post)

Collaboration and contributors

Ideas, code collaboration or any other contributions of any kind is highly appreciated! Fork the repository, add your code.

sqlserver-data-lineage's People

Contributors

tomaztk avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

sqlserver-data-lineage's Issues

v0.4.2

Discussed in #4

Originally posted by tomaztk September 15, 2022
The initial release (minor changes) of T-SQL Data lineage script for SQL Server databases (SQL Server, Azure SQL server, Azure Database, Azure Edge, Azure MI, and Azure Synapse)


This discussion was created from the release v0.4.2.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.