# @veelit/sql-db-analyzer

> MSSQL Analyzer and VC tool

Latest version **2.0.3** (published 2021-11-27) · GPL-3.0-or-later license · 0 weekly downloads

## Install

```sh
npm install @veelit/sql-db-analyzer
pnpm add @veelit/sql-db-analyzer
yarn add @veelit/sql-db-analyzer
bun add @veelit/sql-db-analyzer
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.3 |
| Published | 2021-11-27 |
| First published | 2021-11-22 |
| Weekly downloads | 0 |
| License | GPL-3.0-or-later |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 11 |
| Unpacked size | 35.2 KB |
| Known vulnerabilities | 0 (+4 in 1 direct dependencies) |
| Install scripts | no |
| Author | r2g |
| Maintainers | r2g |

## Links

- npm: https://www.npmjs.com/package/@veelit/sql-db-analyzer
- Repository: https://github.com/veelit-plugins/mssql-analyzer
- Homepage: https://github.com/veelit-plugins/mssql-analyzer#readme
- Issues: https://github.com/veelit-plugins/mssql-analyzer/issues
- npm.io page: https://npm.io/package/@veelit/sql-db-analyzer

## Dependencies (11)

- [chalk](https://npm.io/package/chalk.md) ^4.1.2
- [clear](https://npm.io/package/clear.md) ^0.1.0
- [mssql](https://npm.io/package/mssql.md) ^7.3.0
- [dotenv](https://npm.io/package/dotenv.md) ^10.0.0
- [moment](https://npm.io/package/moment.md) ^2.29.1
- [tedious](https://npm.io/package/tedious.md) ^9.2.3
- [typeorm](https://npm.io/package/typeorm.md) ^0.2.41
- [fs-extra](https://npm.io/package/fs-extra.md) ^10.0.0
- [sequelize](https://npm.io/package/sequelize.md) ^6.3.5
- [body-parser](https://npm.io/package/body-parser.md) ^1.19.0
- [pretty-exceptions](https://npm.io/package/pretty-exceptions.md) ^1.4.15

## Recent versions

- 2.0.3 (latest) — 2021-11-27
- 2.0.2 — 2021-11-27
- 2.0.1 — 2021-11-27
- 2.0.0 — 2021-11-27
- 1.0.15 — 2021-11-22
- 1.0.14 — 2021-11-22
- 1.0.13 — 2021-11-22
- 1.0.12 — 2021-11-22
- 1.0.11 — 2021-11-22
- 1.0.10 — 2021-11-22
- 1.0.9 — 2021-11-22
- 1.0.8 — 2021-11-22
- 1.0.7 — 2021-11-22
- 1.0.6 — 2021-11-22
- 1.0.5 — 2021-11-22
- … 2 more at https://npm.io/package/@veelit/sql-db-analyzer/versions

## README

# SQL Database Analyzer

The Sql Database Analyzer tool enables you to analyze an SQL Database and obtain its `Functions`, `Table Schemas`, `Stored Procedures`
and `Data` in JSON format.

It currently supports `Microsoft SQL Server Databases` with plans to support `Postgres SQL` and `SQLite` in the pipeline

## Installation

```cmd
npm install @veelit/sql-db-analyzer
```

or

```
yarn add @veelit/sql-database-analyzer
```

## Usage

```javascript
// ESM Modules
import { MSSQLAnalyzer } from "@veelit/sql-db-analyzer";
import { resolve } from "path";
import dotEnv from "dotenv";

const envPath = resolve(__dirname, "./.env");
dotEnv.config({ path: envPath });

(async () => {
  const options = {
    connection: {
      host: process.env.DB_HOST,
      port: process.env.DB_PORT, // defaults to 1386
      user: process.env.DB_USER,
      pass: process.env.DB_PASS,
      database: process.env.DB_NAME,
    },
    saveTo: "./analysis",
  };

  await new MSSQLAnalyzer(options).run();
})();
```

## Getting a Data Dump

Ensure this SP is available in your MSSQL database

```
CREATE PROCEDURE [dbo].[A_SP_GET_TABLE_DATA] (
	@tableName SYSNAME
)
AS
BEGIN
	SET NOCOUNT ON;
	DECLARE @result NVARCHAR(max);
    DECLARE @DynamicSQL NVARCHAR(max);

    SET @DynamicSQL = N'SELECT * FROM [' + @tableName + '] FOR JSON AUTO';
    EXECUTE sp_executesql @DynamicSQL
	PRINT @DynamicSQL;
END
```

## Output

![image](https://iili.io/5UgNRf.png)

---
_Source: https://npm.io/package/@veelit/sql-db-analyzer · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
