To export your MsSQL databases as a query to be used as a backup or to restore data on a new database, you will need to download and install SQL Server Management Studio (SSMS) which is the free SQL management software.
Now that SSMS is installed, open a new connection to your database using the details provider. When entering in the server with the IP and port, make sure to use a comma (",") between the IP and port number, as shown below:
Now you have gained access to your SQL database, use the navigation to find and select the database you wish to backup and right click on the database name and select Tasks -> Generate Scripts (as shown in the image below)
You will be provided with an introduction to the options you have available for generating the scripts.
Click next to bring up the selection process, this allows you to export certain tables or the entire database with all its objects. We recommend selecting all, unless you large tables that require to be downloaded separately.
After you have selected what you want to export, you need to set the scripting options and the most important step is to ensure you enter the 'Advanced' options and ensure you change the "Types of data to script" option from "Schema only" to "Schema and data" to ensure all data is pulled out into the export script.
Now everything is configured, you can set the output option, in most cases you will want to export this as a script file.
Going through the final steps which are the summary of the script and processes the export, once completed you should now have the file or query on your screen to use to restore your data.