Friday , December 27 2024

How To Get Script of the Entire Database On SQL Server(Generate Script Method)

 

We can not take the backup of the database and transfer it to the test environment for security reasons.

Because the actual data should not be in the test environment due to the security of information.

Therefore, sometimes we need to transfer the actual database structure to the test environment.

We may need to get the script of a database, or some object in the database, without the data in it.

First of all, I am restoring the full backup of the Adventure Work database downloaded from the internet to the instance named TESTINSTACE.

In the article titled “Backup Restore On SQL Server“, you can find out how to perform the restore operation.

Right-click on the database named AdventureWorks2014 via SSMS and call Tasks-> Generate Scripts.

 

We are proceeding by selecting Do not show this page again on the first screen.

 

On the next screen, select “Script entire database and all database objects” as below to create the create script of everything belonging to the database.

 

We call next by choosing as above.

The following screen asks where to save the Script.

I select the Save to new query window option to open a new query screen and move it there.

 

If you choose Save to Clipboard you will be as if you copied the script. You can paste it to the desired tab with ctrl v.

If you choose save to file option, you can also save it into a file with sql extension.

In the next steps, we finish the process by clicking next and finish without selecting another option.

 

Loading

About dbtut

We are a team with over 10 years of database management and BI experience. Our Expertises: Oracle, SQL Server, PostgreSQL, MySQL, MongoDB, Elasticsearch, Kibana, Grafana.

Leave a Reply

Your email address will not be published. Required fields are marked *