Frage

I am new to sql scripting. I have a problem where I sometimes run a standalone mode that doesn't allow a connection from my database to my actual program. I am trying to automate a way to take the data out of my sql server database and push it to my program somehow. Just as a backup.

Is this possible?

War es hilfreich?

Lösung

Source: fmsinc.com/free/NewTips/SQL/SQLServerExpr..

Download and install the SQL Server Management Studio Express interface from the following URL (if you do not already have this utility installed on your server): http://www.microsoft.com/downloads/details.aspx?FamilyID=c243a5ae-4bd1-4e3d-94b8-5a0f62bf7796&displaylang=en

Please note that an installation of SQL Server Express does not install this interface (at the time this article was created for the 2005 version). This is a separate download.

Open the SQL Server Management Studio Express interface.

Create a new backup device using the wizard (expand Server Objects => New Backup Device).

Right click on the new backup device and select the database that you wish to backup.

Select the backup type (most often this is “Full”).

Choose a name for the job. Insert a description if you would like.

Click the Add button to add a Device Destination (this is where you would like the backup .bak output file to be placed).

Click Ok. The backup device is now setup. Repeat steps 3-7 for each database that you wish to backup.

Create a batch file using the following syntax (this is used to execute the backup device).
A syntax example is below (remember to save this file with a “BAT” file extension):

===< Begin Code Batch Script  >===
sqlcmd -S MYSERVER\OFFICESERVERS -E -Q "BACKUP DATABASE MASTER TO TEST"
===< End Code Batch Script >=====
..where “MYSERVER” is the name of the SQL Server machine.
..where “OFFICESERVERS” is the name of the SQL Server.
..where “Test” is the name of the backup job.
..where “MASTER” is the name of the database.

Finally, open the Microsoft Windows Scheduler and assign the batch file created above to a scheduled event. Set the event to run at the point you wish.


EDIT: As you asked if 2 peoples are working remotely - in that case one will be server or both will be clients. What you can do is to create backup file on Server & the get that backup file for client OR in other case define 2 different Jobs & set their starting points for each of them. A backup file will be created for each job that will be executed & get that from destination for each client.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top