Skip to content

Commit a96187e

Browse files
docs: Update README with extra examples (#70)
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
1 parent cf26ff9 commit a96187e

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

README.md

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,27 @@ The application will output the new create or alter view statement that can be u
3434
The generated statement will include a starting comment containing the original statement (can be used to restore the original code) which is also used when the view is reused in other views to start working from the original statement.
3535
Other included information will be the different views that were used, how many select columns and joins that were stripped.
3636

37+
### Using a view definition from a local file
38+
``sqlinliner -vp "./views/MyView.sql" --strip-unused-joins``
39+
40+
This scenario inlines the view defined in `MyView.sql`, with unused join stripping enabled (via `--strip-unused-joins`).
41+
When a file path is specified for the main view, the tool uses the exact contents of that file. If a connection
42+
string is also supplied, any views referenced *within* `MyView.sql` are fetched from the database.
43+
44+
### Disabling the CREATE OR ALTER wrapper
45+
``sqlinliner -vp "./views/MyView.sql" --generate-create-or-alter false``
46+
47+
Pass `--generate-create-or-alter false` when you only need the inlined `SELECT`
48+
statement. This can be useful when embedding the statement inside a larger
49+
script or when comparing different versions of the SQL.
50+
51+
### Keeping all joins in the final statement
52+
``sqlinliner -cs "Server=.;Database=Test;Integrated Security=true" -vn "dbo.VHeavy" --strip-unused-joins false``
53+
54+
This variant keeps every join from nested views but will still remove unused
55+
columns. It can be handy when you want the view expanded but prefer to control
56+
join optimization yourself.
57+
3758
### Additional options
3859

3960
Two optional parameters can be used to control where the generated SQL and debug information are written:
@@ -50,4 +71,4 @@ select * from dbo.VHeavy except select * from dbo.VHeavy_v2
5071
select * from dbo.VHeavy_v2 except select * from dbo.VHeavy
5172
```
5273

53-
Should return 0 results for both queries.
74+
Should return 0 results for both queries.

0 commit comments

Comments
 (0)