https://github.com/zlepper/mssql-validator
https://github.com/zlepper/mssql-validator
Last synced: 5 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/zlepper/mssql-validator
- Owner: zlepper
- Created: 2021-03-22T18:55:46.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2022-05-27T12:22:19.000Z (about 4 years ago)
- Last Synced: 2025-05-16T07:41:34.023Z (about 1 year ago)
- Language: C#
- Size: 16.6 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# MSSQL Validator
Validates that your T-SQL files are valid T-SQL.
## Example
This will checkout your code and validate all files in the `scripts` directory, that ends in .sql, recursively.
```yaml
name: SQL
on:
push:
jobs:
validate-sql:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Validate SQL
uses: zlepper/mssql-validator@v1
with:
pattern: 'scripts/**/*.sql'
```
## Parameters
|name|description|
|----|-----------|
|pattern|The file glob pattern to use to find files to check. Uses [DotNet.Glob](https://github.com/dazinator/DotNet.Glob) for matching, so check their documentation for more information on what patterns are supported|
## How does it work
Internally there is a tiny C# program, seen in the `Validator` folder, which connects to a sql server
instance that is running inside the same docker image, and then uses [`SET PARSEONLY ON`](https://docs.microsoft.com/en-us/sql/t-sql/statements/set-parseonly-transact-sql?view=sql-server-ver15) to "execute" the code. That way only the syntax itself is validated, and it doesn't requite a database that actually exists, or a potential slow execution of all the scripts.
This also means, that it doesn't validate that you code will actually work, just that it is valid T-SQL, and that you at least shouldn't get a syntax error when trying to run the code.