c# - Breakdown / Documentation of a SQL Query -




i have large, complex, , undocumented database. have task provide document show tables , columns have been used stored procedures, functions, etc.

according research majority of queries have similar format this:

select u.firstname , u.lastname, a.accountnumber username u left join account on a.userid = u.userid 

~90% of tables , columns have aliases.

further, have table 2 columns - function/sproc name, , sql code.

i looking method (preferably sql, can c#) output following results above sql code:

  • username - firstname
  • username - lastname
  • username - userid
  • account - userid
  • account - accountnumber

what best approach achieve this? have tried join each sql code cell information_schema.columns inaccurate results, when column name appears in columns table, not used specific table in sql code cell.

thanks

probably want @ dependencies on stored procedure/function looking at?

take @ https://www.mssqltips.com/sqlservertip/1768/identifying-object-dependencies-in-sql-server/

e.g. if procedure name dbo.myproc, below

select '* ' + referenced_entity_name + ' - ' + referenced_minor_name sys.dm_sql_referenced_entities ('dbo.myproc', 'object') referenced_minor_name not null; 




wiki

Comments

Popular posts from this blog

Asterisk AGI Python Script to Dialplan does not work -

python - Read npy file directly from S3 StreamingBody -

kotlin - Out-projected type in generic interface prohibits the use of metod with generic parameter -