Copying mssql DB to laravel sail docker container - sql-server

The bounty expires in 3 days. Answers to this question are eligible for a +50 reputation bounty.
user101289 wants to draw more attention to this question.
I'm trying to use SqlServer as my DB repo in a laravel project running in sail.
Here's the relevant lines from the laravel docker-compose.yml
mssql:
image: 'mcr.microsoft.com/mssql/server:2022-latest'
ports:
- '${MSSQL_FORWARD_DB_PORT:-1432}:1433' // running on nonstandard port because I have other containers running
environment:
ACCEPT_EULA: "Y"
MSSQL_SA_PASSWORD: "MyDBP#ssword!1"
networks:
- sail
volumes:
- 'sail-mssql:/data/mssql'
I can connect to the Docker SqlServer instance from SSMS using my expected connection of tcp:localhost,1432 but when I try to run the "copy" operation from a local DB to the remote container, it gives the following error:
TITLE: Copy Database Wizard
------------------------------
The action you attempted to perform on a remote SQL Server instance failed because the
action requires a SQL Server component that is not installed on the remote computer. To
proceed, install Microsoft SQL Server Management Tools on the remote computer, and then
try again. For more information, see "How to: Install Microsoft SQL Server (Setup)" in
Microsoft SQL Server Books Online, or find the article on MSDN at
https://go.microsoft.com/fwlink/?LinkID=57083 .
For help, click: https://go.microsoft.com/fwlink/?LinkID=57083
------------------------------
BUTTONS:
OK
------------------------------
Naturally, the URL returns a 404 on the MS docs site, and every MSDN article I can find simply tells me to install SQL Server command-line tools instead Microsoft SQL Server Management Tools. This doesn't help unfortunately-- the command line tools are already installed with the docker image.
Is it possible to copy a DB from a Windows machine to Docker via SSMS

It's possible to copy a database from a Windows machine to a SQL Server instance running in a Docker container using SQL Server Management Studio (SSMS), but you may need to use a different method than the Copy Database Wizard.
One way to do this is by using the Generate Scripts wizard in SSMS to create a script that contains the schema and data of the source database, and then running that script on the SQL Server instance running in the Docker container.
Here are the general steps:
In SSMS on the Windows machine, connect to the source SQL Server instance and right-click on the database you want to copy.
Select Tasks > Generate Scripts to start the Generate Scripts wizard.
Follow the wizard to select the objects and options you want to include in the script. Be sure to select "Schema and data" for the "Types of data to script" option.
On the "Set Scripting Options" page, click the "Advanced" button and set the "Script for server version" option to the version of SQL Server running in the Docker container.
Save the script to a file.
Copy the script file to the Docker container running SQL Server. You can use the docker cp command to do this.
In SSMS on the Docker container, connect to the SQL Server instance and open a new query window.
Open the script file in SSMS and run it to create the database.
This method may not be the most efficient or practical for very large databases or frequent copying of databases. In those cases, you may want to consider using other methods, such as by SQL Server Native Client.

Related

SQL backup file made with MSSMS is not working... on MSSMS (Microsoft SQL Server Management Studio)

I Generated an SQL File to backup a database using MSSMS:
Right click on database
Generate scripts
Marked "Schema and data" on "Types of data to script"
As a result I got a complete SQL that effectively seems to contain all the needed information to rebuild my db from scratch, data included.
To test it, I tried to run it locally, and found myself stuck because MSSMS is throwing errors on the SQL Script that it itself made.... I does not make any sense :(
Am I missing sth?:
This is the first lines of the sql file just as MSSMS made it:
Any ideas?
EDIT 1
This is the error I get after removing all "ALTER DATABASE" (I assumed those were the configuration specifications that were causing trouble)
It now says the tables are already created though they are not present in the database (it did create the database tough, It's a progress!)
The script you are trying to execute contains elements that are not valid because the edition of SQL you are running locally is not the same as the edition of SQL used to generate the script.
In your case, the script was generated from azure SQL, but you are running it on sql server express edition (localdb)
Remove the azure SQL specific elements and it will work.
The default scripting option in SSMS object explorer is the same database engine type and edition as the source database. It seems the source database is Azure SQL Database based on the CREATE DATABASE syntax so the script will not run against a stand-alone instance like your LocalDB instance.
You can either modify the script or generate a new script appropriate for your target instance. To generate a script for SQL Express LocalDB, click on the Advanced button on the Set Scripting Options page of the Generate Scripts wizard. Select these options:
Script for the database engine edition: Microsoft SQL Server Express Edition
Script for the database engine type: Stand-alone instance

Creating a database instance after having installed SQL Server Management Studio

I have installed the SQL Server Management Studio (v. 17.9.1) but I am not able to create an instance.
In fact no server appears in the box when I browse:
How can I proceed, step by step, to create a local instance?
You can create a local Database by using the command prompt. As open cmd with Admin privilege, > sqllocaldb create "database name" -s(start with it) . There is lot of option with sqllocaldb read there.
Go to windows services (services.msc) and check if SQL Server and SQL Server Browser are running. If not, start them and you should be able to login and create the DB.
type in sql server download in your browser and go to microsoft's website. You have downloaded SSMS but you do not have a server installed. Download SQL express or SQL developer edition and install. Once you have done this you will have a default instance (or named if you customized the install). I must have hit this posting 4 times trying to figure this out but now I'm off and running. If you want a test database to play with you can then download adventureworks (again just use your browser (sql adventureworks) and download the backup file. You can restore it by clicking on the databases folder once you have connected to your sql instance in SSMS.

Configure remote connections without sql server installation?

We have an application called IpSwitch Whatsup and it's installed in a machine that I can connect to remotely as administrator. This is all in our intranet.
We need to connect to the sql server database being used by IpSwitch Whatsup, but this particular machine doesn't have sql server installed. On the other hand, in sql server configuration manager there is indeed a sql server installation for whatsup (the entry says SQL Server (WHATSUP)).
So, two questions:
How does one go about in connecting to this database? I'm pretty sure I know the name of the database and I already know the server name and instance, so I would like to connect to this DB from a sql server installation in another machine.
How does one configure a sql server installation to receive remote connections if it doesn't have sql server installed?
Thanks.
For the first question, you just type in (or browse) the appropriate instance name and authentication options using SSMS - which is the GUI tool used to manage sql server instances. Note - the term "sql server installation" can mean different things so it is not a useful reference.
As for the second question, review the information here. Note that any task you do in SSMS can be done via tsql - you can see the appropriate commands using the script button in the SSMS dialog windows.
And you can also (and probably should based on these questions) install SSMS on the same machine as your server instance so you can do "anything" "anywhere". Now would probably be a good time to review your disaster recovery options (and start backing up your databases regularly).

Neo4j ETL jdbc SQL Server driver

I'm working with Neo4j desktop. I successfully installed the ETL tool but on the database configuration, I can see only the Mysql and portage default.
I downloaded the SQL Server driver and unzipped it into my active database lib directory, but the SQL Server database type option did not appear on the menu.
Please advice
Tal
Tal, currently the sql-server support only works with the command line tool.
Please follow the instructions there:
https://neo4j-contrib.github.io/neo4j-etl/#neo4j-etl-cli
Make sure to use the correct JDBC URL for SQL Server.
Here is a Docker example for SQL Server
https://neo4j-contrib.github.io/neo4j-etl/#_microsoft_sql

Deploy SQL Server and my dataBase with oneClick setup

I'm asking if it's possible to deploy SQL Server and my database with oneClick setup.
I'm mean that I have to give to my client the setup file that contains my application and my database. The user should just have to click on the setup, and automatically install my application, SQL Server and deploy the database in one operation.
Is that possible?
Thanks but I
need alos to know how to deply te SQL SERVER 2008 runTime?
I mean after installing the application, I have to instal the SQL Server and then deploy the database
You can script all the objects in a database via the SSMS by right clicking on the db -> Tasks -> Generate Scripts -> Check Script All Objects in this database. Save the script to a .sql file and execute it against their SQL Server Instance.
Of course it is possible, your client just needs to provide SQL Server credentials during setup and your code can execute scripts during setup to create all the necessary database objects. If this doesn't fit your definition of "oneClick" than you would need to have this information ahead of time and include it in your installation but that would not be secure and it doesn't make much sense because you'd than have to create a unique setup for each client...

Resources