HOWTO-Get-T-SQL-Into-SSDT

Ok so you have created an SSDT project and are currently congratulating yourself on how awesome and cool you are but then you realise that your project is like an empty void, completely devoid of any emotion, love or joy - there is no schema and code in the project and you have all that lovely T-SQL sitting in a database, now how the hell do you get it into SSDT?

Easy

First of all, let's think about it like this:

You can Import, use schema compare or type stuff in

So the options are:

1 - Import

You can import into an empty project from a dacpac or a live database, just right click on the project, choose "Import" and then dacpac or Database. You can only use these options on an empty project.

You can additionally import from a script file at anytime, whether the project is empty or not. If you choose to import from a script you can either import a single file or multiple files, which is useful if you have lots of files to import.

2 - Schema Compare

If you create a schema compare in SSDT, either right click the project and choose "Schema Compare" or browse to a database in the Sql Server Object Explorer, right click (the database) and also choose "Schema Compare", set the source of the compare to the live database and the target to be the project you want to update and then do a compare and an update and bob is your uncle.

3 - Fingers

The last option is to type stuff in, it isn't very difficult and you can make it do exactly what you want!

But I want to import a dacpac into an existing project, boo hoo hoo

You could import to a new one and copy and paste the files into your actual project, that would work nicely.

A short post today but hopefully useful. Just a little reminder that if anyone wants some free help to get started with CI or agile sql practices then give me a shout, either by email or give me a call, full details:

https://the.agilesql.club/Blogs/Ed-Elliott/Professional-Advice-on-Settin...

Add new comment