Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
shapper
Constraint Violating Yak Guru
450 Posts |
Posted - 2010-06-16 : 09:09:27
|
| Hello,Is it possible to backup and restore a database using T-SQL?I need to backup the database, log and filegroup to a specific folder and verify that everything is ok.And later I would like to restore it.I suppose I can't backup and restore the User, Login, Role, etc ...Thank You,Miguel |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2010-06-16 : 09:12:46
|
The easy way is to do it in the dialog in SSMS and then don't execute it but click on [Script] (it is a button near to the Help button). No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
Lumbago
Norsk Yak Master
3271 Posts |
Posted - 2010-06-16 : 09:23:52
|
Everything you can do in the gui you can also do using tsql scripts. Do as webfred says and click the script button or locate scripts for just about everything here on sqlteam or on the web. Here is a very simple script for backup:BACKUP DATABASE MyDatabaseName TO DISK = 'c:\backups\MyDBBackup_20100616.bak' WITH CHECKSUM To do a restore is somewhat more complex but there is a script you can use to generate the restore command for you which makes it a whole lot easier: http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=101995- LumbagoMy blog (yes, I have a blog now! just not that much content yet) -> www.thefirstsql.com |
 |
|
|
|
|
|