开发者

Moving a database from my development PC to a client PC without SQL Server Managment Studio?

开发者 https://www.devze.com 2023-03-27 00:42 出处:网络
I have created one Winforms application on my PC with SQL Server as its database. I have installed my application on a cli开发者_Python百科ent PC, and I am required to copy the database I have create

I have created one Winforms application on my PC with SQL Server as its database.

I have installed my application on a cli开发者_Python百科ent PC, and I am required to copy the database I have created on my PC.

I don't want to install entire SQL Server Management Studio on the client PC.

Can I just install SQL Server on the client PC and add my database to that without installing SQL Server Management Studio?

How can this be done?


You don't need management studio. You can use sqlcmd (2005/2008) http://msdn.microsoft.com/en-us/library/ms162773.aspx or osql (2000) http://msdn.microsoft.com/en-us/library/aa214012(v=sql.80).aspx

You'll need to backup and restore the DB through TSQL commands

e.g.

BACKUP DATABASE AdventureWorks2008R2 
TO DISK = 'Z:\SQLServerBackups\AdvWorksData.bak'
WITH FORMAT;

Then, on the target server

RESTORE DATABASE AdventureWorks2008R2
FROM DISK = 'Z:\SQLServerBackups\AdventureWorks2008R2.bak'

You can also connect to the remote server with SSMS on a different box if network/policy allows.


You can do this (see magicmike's answer), but did you also think about how the client will be able to take backups of his database?

Maybe the client has already installed SSMS on some other machine (then he can backup his new database from there) or he knows enough SQL Server to set up the backup only with T-SQL and the Windows Task Scheduler.
If not, you might want to consider installing SQL Server with Management Studio.


This is good link i have fond.

below is snippet [coz link may broken]

To BACKUP and RESTORE DataBase through SQLCMD.EXE :

sqlcmd -S.\SQLExpress
1> BACKUP DATABASE dbName TO DISK = 'path'
2> GO
An alternative, single-line backup command:

sqlcmd -S.\SQLExpress -Q"BACKUP DATABASE dbName  TO DISK = 'path'"
(Note that you must enclose the path within quotes)

To Restore:

sqlcmd -S.\SQLExpress
1> RESTORE DATABASE dbName FROM DISK = 'path'
2> GO

For Restore with REPLACING EXISTING DATABASE
1> RESTORE DATABASE dbName FROM DISK = 'path'
2> WITH REPLACE
3> GO
0

精彩评论

暂无评论...
验证码 换一张
取 消