Skip to content

Commit

Permalink
[Docs] Show how to extract an existing database (#661)
Browse files Browse the repository at this point in the history
* Show how to extract an existing database

* add link to docs

* Respond to feedback
ErikEJ authored Nov 18, 2024
1 parent a233617 commit 7abd55e
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -81,6 +81,25 @@ If you are using Visual Studio, to make files excluded from the package appear i

Wildcards are supported for all nodes (`Content`, `None`, etc.). For example, `<None Include="Directory\**" />`.


## Use an existing database

If you want to initialize your project with scripted objects from an existing database, you can do so with the following command:

```
sqlpackage /Action:Extract /Properties:ExtractTarget=Flat /SourceConnectionString:"<connection_string>" /TargetFile:<target_new_folder>
```

For example:

```
sqlpackage /a:Extract /p:ExtractTarget=Flat /scs:"data source=.\SQLEXPRESS;initial catalog=Chinook;Trusted_Connection=true;encrypt=False" /tf:.\Tables
```

> Note: The /tf parameter is currently required, and must refer to a non-existing folder.
You can read more about the `sqlpackage /a:Extract` command syntax [here](https://learn.microsoft.com/sql/tools/sqlpackage/sqlpackage-extract).

## Item templates
To create database objects you can use the following item templates:

0 comments on commit 7abd55e

Please sign in to comment.