Need to restore the db from network location.
After I click restore from device. The select path box is grayed out. I
could not type the network path.
(I know i could restore it in query analyzer by using restore code.)
Any ideas?
ThanksDid you press the ... button to the right of that text box?
--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"mecn" <mecn2002@.yahoo.com> wrote in message news:ud2imO78GHA.4224@.TK2MSFTNGP02.phx.gbl...
> Need to restore the db from network location.
> After I click restore from device. The select path box is grayed out. I
> could not type the network path.
> (I know i could restore it in query analyzer by using restore code.)
> Any ideas?
> Thanks
>|||I did, Just let you select local divers only
"Tibor Karaszi" <tibor_please.no.email_karaszi@.hotmail.nomail.com> wrote in
message news:%23mgSe1B9GHA.3916@.TK2MSFTNGP04.phx.gbl...
> Did you press the ... button to the right of that text box?
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://www.solidqualitylearning.com/
>
> "mecn" <mecn2002@.yahoo.com> wrote in message
> news:ud2imO78GHA.4224@.TK2MSFTNGP02.phx.gbl...
>> Need to restore the db from network location.
>> After I click restore from device. The select path box is grayed out. I
>> could not type the network path.
>> (I know i could restore it in query analyzer by using restore code.)
>> Any ideas?
>> Thanks|||mecn wrote:
> I did, Just let you select local divers only
>
Correct, you can't point/click to a network path, but you can TYPE the
path into the filename field on that same window...
Tracy McKibben
MCDBA
http://www.realsqlguy.com|||The problem is I could not. The box is grayed out.
"Tracy McKibben" <tracy@.realsqlguy.com> wrote in message
news:4538D8BB.7050509@.realsqlguy.com...
> mecn wrote:
>> I did, Just let you select local divers only
> Correct, you can't point/click to a network path, but you can TYPE the
> path into the filename field on that same window...
>
> --
> Tracy McKibben
> MCDBA
> http://www.realsqlguy.com|||I couldn't type. Is it sort of permission issue?
Thanks
"Tracy McKibben" <tracy@.realsqlguy.com> wrote in message
news:4538D8BB.7050509@.realsqlguy.com...
> mecn wrote:
>> I did, Just let you select local divers only
> Correct, you can't point/click to a network path, but you can TYPE the
> path into the filename field on that same window...
>
> --
> Tracy McKibben
> MCDBA
> http://www.realsqlguy.com|||sorry. you are saying that I could type the network path in to the file name
box?
i.e. \\network\servover\dir\abc.bak?
Thanks
"Tracy McKibben" <tracy@.realsqlguy.com> wrote in message
news:4538D8BB.7050509@.realsqlguy.com...
> mecn wrote:
>> I did, Just let you select local divers only
> Correct, you can't point/click to a network path, but you can TYPE the
> path into the filename field on that same window...
>
> --
> Tracy McKibben
> MCDBA
> http://www.realsqlguy.com|||I don't think taht you could type the path and file name into filename box.
Filename box is only for file name like abc.bak. right?!
"Tracy McKibben" <tracy@.realsqlguy.com> wrote in message
news:4538D8BB.7050509@.realsqlguy.com...
> mecn wrote:
>> I did, Just let you select local divers only
> Correct, you can't point/click to a network path, but you can TYPE the
> path into the filename field on that same window...
>
> --
> Tracy McKibben
> MCDBA
> http://www.realsqlguy.com|||I am sorry, you are right!!!! I could type the network path into file name
box and it works--THANK YOU VERY MUCH!!!@.!!
"Tracy McKibben" <tracy@.realsqlguy.com> wrote in message
news:4538D8BB.7050509@.realsqlguy.com...
> mecn wrote:
>> I did, Just let you select local divers only
> Correct, you can't point/click to a network path, but you can TYPE the
> path into the filename field on that same window...
>
> --
> Tracy McKibben
> MCDBA
> http://www.realsqlguy.com|||mecn wrote:
> I am sorry, you are right!!!! I could type the network path into file name
> box and it works--THANK YOU VERY MUCH!!!@.!!
>
Great... Now that you've accomplished that, can you explain why this
was easier than just issuing the RESTORE DATABASE command in a query window?
Tracy McKibben
MCDBA
http://www.realsqlguy.com
Showing posts with label select. Show all posts
Showing posts with label select. Show all posts
Friday, March 30, 2012
restore db from device in sql2005
Need to restore the db from network location.
After I click restore from device. The select path box is grayed out. I
could not type the network path.
(I know i could restore it in query analyzer by using restore code.)
Any ideas?
Thanks
Did you press the ... button to the right of that text box?
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"mecn" <mecn2002@.yahoo.com> wrote in message news:ud2imO78GHA.4224@.TK2MSFTNGP02.phx.gbl...
> Need to restore the db from network location.
> After I click restore from device. The select path box is grayed out. I
> could not type the network path.
> (I know i could restore it in query analyzer by using restore code.)
> Any ideas?
> Thanks
>
|||I did, Just let you select local divers only
"Tibor Karaszi" <tibor_please.no.email_karaszi@.hotmail.nomail.com> wrote in
message news:%23mgSe1B9GHA.3916@.TK2MSFTNGP04.phx.gbl...[vbcol=seagreen]
> Did you press the ... button to the right of that text box?
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://www.solidqualitylearning.com/
>
> "mecn" <mecn2002@.yahoo.com> wrote in message
> news:ud2imO78GHA.4224@.TK2MSFTNGP02.phx.gbl...
|||mecn wrote:
> I did, Just let you select local divers only
>
Correct, you can't point/click to a network path, but you can TYPE the
path into the filename field on that same window...
Tracy McKibben
MCDBA
http://www.realsqlguy.com
|||The problem is I could not. The box is grayed out.
"Tracy McKibben" <tracy@.realsqlguy.com> wrote in message
news:4538D8BB.7050509@.realsqlguy.com...
> mecn wrote:
> Correct, you can't point/click to a network path, but you can TYPE the
> path into the filename field on that same window...
>
> --
> Tracy McKibben
> MCDBA
> http://www.realsqlguy.com
|||I couldn't type. Is it sort of permission issue?
Thanks
"Tracy McKibben" <tracy@.realsqlguy.com> wrote in message
news:4538D8BB.7050509@.realsqlguy.com...
> mecn wrote:
> Correct, you can't point/click to a network path, but you can TYPE the
> path into the filename field on that same window...
>
> --
> Tracy McKibben
> MCDBA
> http://www.realsqlguy.com
|||sorry. you are saying that I could type the network path in to the file name
box?
i.e. \\network\servover\dir\abc.bak?
Thanks
"Tracy McKibben" <tracy@.realsqlguy.com> wrote in message
news:4538D8BB.7050509@.realsqlguy.com...
> mecn wrote:
> Correct, you can't point/click to a network path, but you can TYPE the
> path into the filename field on that same window...
>
> --
> Tracy McKibben
> MCDBA
> http://www.realsqlguy.com
|||I don't think taht you could type the path and file name into filename box.
Filename box is only for file name like abc.bak. right?!
"Tracy McKibben" <tracy@.realsqlguy.com> wrote in message
news:4538D8BB.7050509@.realsqlguy.com...
> mecn wrote:
> Correct, you can't point/click to a network path, but you can TYPE the
> path into the filename field on that same window...
>
> --
> Tracy McKibben
> MCDBA
> http://www.realsqlguy.com
|||I am sorry, you are right!!!! I could type the network path into file name
box and it works--THANK YOU VERY MUCH!!!@.!!
"Tracy McKibben" <tracy@.realsqlguy.com> wrote in message
news:4538D8BB.7050509@.realsqlguy.com...
> mecn wrote:
> Correct, you can't point/click to a network path, but you can TYPE the
> path into the filename field on that same window...
>
> --
> Tracy McKibben
> MCDBA
> http://www.realsqlguy.com
|||mecn wrote:
> I am sorry, you are right!!!! I could type the network path into file name
> box and it works--THANK YOU VERY MUCH!!!@.!!
>
Great... Now that you've accomplished that, can you explain why this
was easier than just issuing the RESTORE DATABASE command in a query window?
Tracy McKibben
MCDBA
http://www.realsqlguy.com
After I click restore from device. The select path box is grayed out. I
could not type the network path.
(I know i could restore it in query analyzer by using restore code.)
Any ideas?
Thanks
Did you press the ... button to the right of that text box?
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"mecn" <mecn2002@.yahoo.com> wrote in message news:ud2imO78GHA.4224@.TK2MSFTNGP02.phx.gbl...
> Need to restore the db from network location.
> After I click restore from device. The select path box is grayed out. I
> could not type the network path.
> (I know i could restore it in query analyzer by using restore code.)
> Any ideas?
> Thanks
>
|||I did, Just let you select local divers only
"Tibor Karaszi" <tibor_please.no.email_karaszi@.hotmail.nomail.com> wrote in
message news:%23mgSe1B9GHA.3916@.TK2MSFTNGP04.phx.gbl...[vbcol=seagreen]
> Did you press the ... button to the right of that text box?
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://www.solidqualitylearning.com/
>
> "mecn" <mecn2002@.yahoo.com> wrote in message
> news:ud2imO78GHA.4224@.TK2MSFTNGP02.phx.gbl...
|||mecn wrote:
> I did, Just let you select local divers only
>
Correct, you can't point/click to a network path, but you can TYPE the
path into the filename field on that same window...
Tracy McKibben
MCDBA
http://www.realsqlguy.com
|||The problem is I could not. The box is grayed out.
"Tracy McKibben" <tracy@.realsqlguy.com> wrote in message
news:4538D8BB.7050509@.realsqlguy.com...
> mecn wrote:
> Correct, you can't point/click to a network path, but you can TYPE the
> path into the filename field on that same window...
>
> --
> Tracy McKibben
> MCDBA
> http://www.realsqlguy.com
|||I couldn't type. Is it sort of permission issue?
Thanks
"Tracy McKibben" <tracy@.realsqlguy.com> wrote in message
news:4538D8BB.7050509@.realsqlguy.com...
> mecn wrote:
> Correct, you can't point/click to a network path, but you can TYPE the
> path into the filename field on that same window...
>
> --
> Tracy McKibben
> MCDBA
> http://www.realsqlguy.com
|||sorry. you are saying that I could type the network path in to the file name
box?
i.e. \\network\servover\dir\abc.bak?
Thanks
"Tracy McKibben" <tracy@.realsqlguy.com> wrote in message
news:4538D8BB.7050509@.realsqlguy.com...
> mecn wrote:
> Correct, you can't point/click to a network path, but you can TYPE the
> path into the filename field on that same window...
>
> --
> Tracy McKibben
> MCDBA
> http://www.realsqlguy.com
|||I don't think taht you could type the path and file name into filename box.
Filename box is only for file name like abc.bak. right?!
"Tracy McKibben" <tracy@.realsqlguy.com> wrote in message
news:4538D8BB.7050509@.realsqlguy.com...
> mecn wrote:
> Correct, you can't point/click to a network path, but you can TYPE the
> path into the filename field on that same window...
>
> --
> Tracy McKibben
> MCDBA
> http://www.realsqlguy.com
|||I am sorry, you are right!!!! I could type the network path into file name
box and it works--THANK YOU VERY MUCH!!!@.!!
"Tracy McKibben" <tracy@.realsqlguy.com> wrote in message
news:4538D8BB.7050509@.realsqlguy.com...
> mecn wrote:
> Correct, you can't point/click to a network path, but you can TYPE the
> path into the filename field on that same window...
>
> --
> Tracy McKibben
> MCDBA
> http://www.realsqlguy.com
|||mecn wrote:
> I am sorry, you are right!!!! I could type the network path into file name
> box and it works--THANK YOU VERY MUCH!!!@.!!
>
Great... Now that you've accomplished that, can you explain why this
was easier than just issuing the RESTORE DATABASE command in a query window?
Tracy McKibben
MCDBA
http://www.realsqlguy.com
restore db from device in sql2005
Need to restore the db from network location.
After I click restore from device. The select path box is grayed out. I
could not type the network path.
(I know i could restore it in query analyzer by using restore code.)
Any ideas?
ThanksDid you press the ... button to the right of that text box?
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"mecn" <mecn2002@.yahoo.com> wrote in message news:ud2imO78GHA.4224@.TK2MSFTNGP02.phx.gbl...[v
bcol=seagreen]
> Need to restore the db from network location.
> After I click restore from device. The select path box is grayed out. I
> could not type the network path.
> (I know i could restore it in query analyzer by using restore code.)
> Any ideas?
> Thanks
>[/vbcol]|||I did, Just let you select local divers only
"Tibor Karaszi" <tibor_please.no.email_karaszi@.hotmail.nomail.com> wrote in
message news:%23mgSe1B9GHA.3916@.TK2MSFTNGP04.phx.gbl...[vbcol=seagreen]
> Did you press the ... button to the right of that text box?
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://www.solidqualitylearning.com/
>
> "mecn" <mecn2002@.yahoo.com> wrote in message
> news:ud2imO78GHA.4224@.TK2MSFTNGP02.phx.gbl...|||mecn wrote:
> I did, Just let you select local divers only
>
Correct, you can't point/click to a network path, but you can TYPE the
path into the filename field on that same window...
Tracy McKibben
MCDBA
http://www.realsqlguy.com|||The problem is I could not. The box is grayed out.
"Tracy McKibben" <tracy@.realsqlguy.com> wrote in message
news:4538D8BB.7050509@.realsqlguy.com...
> mecn wrote:
> Correct, you can't point/click to a network path, but you can TYPE the
> path into the filename field on that same window...
>
> --
> Tracy McKibben
> MCDBA
> http://www.realsqlguy.com|||I couldn't type. Is it sort of permission issue?
Thanks
"Tracy McKibben" <tracy@.realsqlguy.com> wrote in message
news:4538D8BB.7050509@.realsqlguy.com...
> mecn wrote:
> Correct, you can't point/click to a network path, but you can TYPE the
> path into the filename field on that same window...
>
> --
> Tracy McKibben
> MCDBA
> http://www.realsqlguy.com|||sorry. you are saying that I could type the network path in to the file name
box?
i.e. \\network\servover\dir\abc.bak?
Thanks
"Tracy McKibben" <tracy@.realsqlguy.com> wrote in message
news:4538D8BB.7050509@.realsqlguy.com...
> mecn wrote:
> Correct, you can't point/click to a network path, but you can TYPE the
> path into the filename field on that same window...
>
> --
> Tracy McKibben
> MCDBA
> http://www.realsqlguy.com|||I don't think taht you could type the path and file name into filename box.
Filename box is only for file name like abc.bak. right?!
"Tracy McKibben" <tracy@.realsqlguy.com> wrote in message
news:4538D8BB.7050509@.realsqlguy.com...
> mecn wrote:
> Correct, you can't point/click to a network path, but you can TYPE the
> path into the filename field on that same window...
>
> --
> Tracy McKibben
> MCDBA
> http://www.realsqlguy.com|||I am sorry, you are right!!!! I could type the network path into file name
box and it works--THANK YOU VERY MUCH!!!@.!!
"Tracy McKibben" <tracy@.realsqlguy.com> wrote in message
news:4538D8BB.7050509@.realsqlguy.com...
> mecn wrote:
> Correct, you can't point/click to a network path, but you can TYPE the
> path into the filename field on that same window...
>
> --
> Tracy McKibben
> MCDBA
> http://www.realsqlguy.com|||mecn wrote:
> I am sorry, you are right!!!! I could type the network path into file name
> box and it works--THANK YOU VERY MUCH!!!@.!!
>
Great... Now that you've accomplished that, can you explain why this
was easier than just issuing the RESTORE DATABASE command in a query window?
Tracy McKibben
MCDBA
http://www.realsqlguy.comsql
After I click restore from device. The select path box is grayed out. I
could not type the network path.
(I know i could restore it in query analyzer by using restore code.)
Any ideas?
ThanksDid you press the ... button to the right of that text box?
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"mecn" <mecn2002@.yahoo.com> wrote in message news:ud2imO78GHA.4224@.TK2MSFTNGP02.phx.gbl...[v
bcol=seagreen]
> Need to restore the db from network location.
> After I click restore from device. The select path box is grayed out. I
> could not type the network path.
> (I know i could restore it in query analyzer by using restore code.)
> Any ideas?
> Thanks
>[/vbcol]|||I did, Just let you select local divers only
"Tibor Karaszi" <tibor_please.no.email_karaszi@.hotmail.nomail.com> wrote in
message news:%23mgSe1B9GHA.3916@.TK2MSFTNGP04.phx.gbl...[vbcol=seagreen]
> Did you press the ... button to the right of that text box?
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://www.solidqualitylearning.com/
>
> "mecn" <mecn2002@.yahoo.com> wrote in message
> news:ud2imO78GHA.4224@.TK2MSFTNGP02.phx.gbl...|||mecn wrote:
> I did, Just let you select local divers only
>
Correct, you can't point/click to a network path, but you can TYPE the
path into the filename field on that same window...
Tracy McKibben
MCDBA
http://www.realsqlguy.com|||The problem is I could not. The box is grayed out.
"Tracy McKibben" <tracy@.realsqlguy.com> wrote in message
news:4538D8BB.7050509@.realsqlguy.com...
> mecn wrote:
> Correct, you can't point/click to a network path, but you can TYPE the
> path into the filename field on that same window...
>
> --
> Tracy McKibben
> MCDBA
> http://www.realsqlguy.com|||I couldn't type. Is it sort of permission issue?
Thanks
"Tracy McKibben" <tracy@.realsqlguy.com> wrote in message
news:4538D8BB.7050509@.realsqlguy.com...
> mecn wrote:
> Correct, you can't point/click to a network path, but you can TYPE the
> path into the filename field on that same window...
>
> --
> Tracy McKibben
> MCDBA
> http://www.realsqlguy.com|||sorry. you are saying that I could type the network path in to the file name
box?
i.e. \\network\servover\dir\abc.bak?
Thanks
"Tracy McKibben" <tracy@.realsqlguy.com> wrote in message
news:4538D8BB.7050509@.realsqlguy.com...
> mecn wrote:
> Correct, you can't point/click to a network path, but you can TYPE the
> path into the filename field on that same window...
>
> --
> Tracy McKibben
> MCDBA
> http://www.realsqlguy.com|||I don't think taht you could type the path and file name into filename box.
Filename box is only for file name like abc.bak. right?!
"Tracy McKibben" <tracy@.realsqlguy.com> wrote in message
news:4538D8BB.7050509@.realsqlguy.com...
> mecn wrote:
> Correct, you can't point/click to a network path, but you can TYPE the
> path into the filename field on that same window...
>
> --
> Tracy McKibben
> MCDBA
> http://www.realsqlguy.com|||I am sorry, you are right!!!! I could type the network path into file name
box and it works--THANK YOU VERY MUCH!!!@.!!
"Tracy McKibben" <tracy@.realsqlguy.com> wrote in message
news:4538D8BB.7050509@.realsqlguy.com...
> mecn wrote:
> Correct, you can't point/click to a network path, but you can TYPE the
> path into the filename field on that same window...
>
> --
> Tracy McKibben
> MCDBA
> http://www.realsqlguy.com|||mecn wrote:
> I am sorry, you are right!!!! I could type the network path into file name
> box and it works--THANK YOU VERY MUCH!!!@.!!
>
Great... Now that you've accomplished that, can you explain why this
was easier than just issuing the RESTORE DATABASE command in a query window?
Tracy McKibben
MCDBA
http://www.realsqlguy.comsql
Wednesday, March 28, 2012
restore databases in T-SQL.
--Drop database
if exists (select * from master.dbo.sysdatabases where name='Test')
drop database Test
GO
--Drop device
if exists (select * from master.dbo.sysdevices where name='mydiskdump')
exec master.dbo.sp_dropdevice mydiskdump
GO
--Create Test database
CREATE DATABASE Test
ON
( NAME = Test_dat,
FILENAME = 'c:\Test.mdf',
SIZE = 5,
MAXSIZE = 50,
FILEGROWTH = 5 )
LOG ON
( NAME = 'Test_log',
FILENAME = 'c:\Test.ldf',
SIZE = 5MB,
MAXSIZE = 25MB,
FILEGROWTH = 5MB )
GO
--add device
EXEC master.dbo.sp_addumpdevice 'disk', 'mydiskdump', 'c:\dump.bak'
GO
CREATE TABLE Test.dbo.tblTest (
col1 char(1)
)
GO
delete Test.dbo.tblTest values
insert into Test.dbo.tblTest values ('a')
GO
--whole backup 1
BACKUP DATABASE Test TO mydiskdump
GO
delete Test.dbo.tblTest values
insert into Test.dbo.tblTest values('b')
GO
--differential backup 1
BACKUP DATABASE Test
TO mydiskdump
WITH DIFFERENTIAL
GO
--whole backup 2
BACKUP DATABASE Test TO mydiskdump
GO
delete Test.dbo.tblTest values
insert into Test.dbo.tblTest values('c')
GO
--differential backup 2
BACKUP DATABASE Test
TO mydiskdump
WITH DIFFERENTIAL
GO
delete Test.dbo.tblTest values
insert into Test.dbo.tblTest values('d')
GO
Am I correct in creating the database and the way of backup?
Would you teach me the senarios that restore the database to 'a','b','c','d'
states?
Thanks in advance.You'll need to add another backup to backup 'd', but something like this
should do:
--Drop database
if exists (select * from master.dbo.sysdatabases where name='Test')
drop database Test
GO
--Drop device
if exists (select * from master.dbo.sysdevices where name='mydiskdump')
exec master.dbo.sp_dropdevice mydiskdump
GO
--Create Test database
CREATE DATABASE Test
ON
( NAME = Test_dat,
FILENAME = 'c:\Test.mdf',
SIZE = 5,
MAXSIZE = 50,
FILEGROWTH = 5 )
LOG ON
( NAME = 'Test_log',
FILENAME = 'c:\Test.ldf',
SIZE = 5MB,
MAXSIZE = 25MB,
FILEGROWTH = 5MB )
GO
--add device
EXEC master.dbo.sp_addumpdevice 'disk', 'mydiskdump', 'c:\dump.bak'
GO
CREATE TABLE Test.dbo.tblTest (
col1 char(1)
)
GO
delete Test.dbo.tblTest
insert into Test.dbo.tblTest values ('a')
GO
--whole backup 1
BACKUP DATABASE Test TO mydiskdump
GO
delete Test.dbo.tblTest
insert into Test.dbo.tblTest values('b')
GO
--differential backup 1
BACKUP DATABASE Test
TO mydiskdump
WITH DIFFERENTIAL
GO
--whole backup 2
BACKUP DATABASE Test TO mydiskdump
GO
delete Test.dbo.tblTest
insert into Test.dbo.tblTest values('c')
GO
--differential backup 2
BACKUP DATABASE Test
TO mydiskdump
WITH DIFFERENTIAL
GO
delete Test.dbo.tblTest
insert into Test.dbo.tblTest values('d')
GO
--whole backup 3
BACKUP DATABASE Test TO mydiskdump
go
restore headeronly from mydiskdump
go
restore database Test from mydiskdump with file = 1, recovery
select * from Test.dbo.tblTest
restore database Test from mydiskdump with file = 1, norecovery
restore database Test from mydiskdump with file = 2, recovery
select * from Test.dbo.tblTest
restore database Test from mydiskdump with file = 3, norecovery
restore database Test from mydiskdump with file = 4, recovery
select * from Test.dbo.tblTest
restore database Test from mydiskdump with file = 5, recovery
select * from Test.dbo.tblTest
go
Note that dump devices can store multiple backup sets. You can get the
backup sets that a dump device contains using the restore headeronly command
which lets you know which backup sets to restore. I'd suggest you consider
naming your backup sets though as this can help work out which backups to
restore as well..
HTH
Regards,
Greg Linwood
SQL Server MVP
"haode" <haode@.hao.com> wrote in message
news:%23eNTtec9DHA.1504@.TK2MSFTNGP12.phx.gbl...
> --Drop database
> if exists (select * from master.dbo.sysdatabases where name='Test')
> drop database Test
> GO
> --Drop device
> if exists (select * from master.dbo.sysdevices where name='mydiskdump')
> exec master.dbo.sp_dropdevice mydiskdump
> GO
> --Create Test database
> CREATE DATABASE Test
> ON
> ( NAME = Test_dat,
> FILENAME = 'c:\Test.mdf',
> SIZE = 5,
> MAXSIZE = 50,
> FILEGROWTH = 5 )
> LOG ON
> ( NAME = 'Test_log',
> FILENAME = 'c:\Test.ldf',
> SIZE = 5MB,
> MAXSIZE = 25MB,
> FILEGROWTH = 5MB )
> GO
> --add device
> EXEC master.dbo.sp_addumpdevice 'disk', 'mydiskdump', 'c:\dump.bak'
> GO
> CREATE TABLE Test.dbo.tblTest (
> col1 char(1)
> )
> GO
> delete Test.dbo.tblTest values
> insert into Test.dbo.tblTest values ('a')
> GO
> --whole backup 1
> BACKUP DATABASE Test TO mydiskdump
> GO
> delete Test.dbo.tblTest values
> insert into Test.dbo.tblTest values('b')
> GO
> --differential backup 1
> BACKUP DATABASE Test
> TO mydiskdump
> WITH DIFFERENTIAL
> GO
> --whole backup 2
> BACKUP DATABASE Test TO mydiskdump
> GO
> delete Test.dbo.tblTest values
> insert into Test.dbo.tblTest values('c')
> GO
> --differential backup 2
> BACKUP DATABASE Test
> TO mydiskdump
> WITH DIFFERENTIAL
> GO
> delete Test.dbo.tblTest values
> insert into Test.dbo.tblTest values('d')
> GO
> Am I correct in creating the database and the way of backup?
> Would you teach me the senarios that restore the database to
'a','b','c','d'
> states?
> Thanks in advance.
>
if exists (select * from master.dbo.sysdatabases where name='Test')
drop database Test
GO
--Drop device
if exists (select * from master.dbo.sysdevices where name='mydiskdump')
exec master.dbo.sp_dropdevice mydiskdump
GO
--Create Test database
CREATE DATABASE Test
ON
( NAME = Test_dat,
FILENAME = 'c:\Test.mdf',
SIZE = 5,
MAXSIZE = 50,
FILEGROWTH = 5 )
LOG ON
( NAME = 'Test_log',
FILENAME = 'c:\Test.ldf',
SIZE = 5MB,
MAXSIZE = 25MB,
FILEGROWTH = 5MB )
GO
--add device
EXEC master.dbo.sp_addumpdevice 'disk', 'mydiskdump', 'c:\dump.bak'
GO
CREATE TABLE Test.dbo.tblTest (
col1 char(1)
)
GO
delete Test.dbo.tblTest values
insert into Test.dbo.tblTest values ('a')
GO
--whole backup 1
BACKUP DATABASE Test TO mydiskdump
GO
delete Test.dbo.tblTest values
insert into Test.dbo.tblTest values('b')
GO
--differential backup 1
BACKUP DATABASE Test
TO mydiskdump
WITH DIFFERENTIAL
GO
--whole backup 2
BACKUP DATABASE Test TO mydiskdump
GO
delete Test.dbo.tblTest values
insert into Test.dbo.tblTest values('c')
GO
--differential backup 2
BACKUP DATABASE Test
TO mydiskdump
WITH DIFFERENTIAL
GO
delete Test.dbo.tblTest values
insert into Test.dbo.tblTest values('d')
GO
Am I correct in creating the database and the way of backup?
Would you teach me the senarios that restore the database to 'a','b','c','d'
states?
Thanks in advance.You'll need to add another backup to backup 'd', but something like this
should do:
--Drop database
if exists (select * from master.dbo.sysdatabases where name='Test')
drop database Test
GO
--Drop device
if exists (select * from master.dbo.sysdevices where name='mydiskdump')
exec master.dbo.sp_dropdevice mydiskdump
GO
--Create Test database
CREATE DATABASE Test
ON
( NAME = Test_dat,
FILENAME = 'c:\Test.mdf',
SIZE = 5,
MAXSIZE = 50,
FILEGROWTH = 5 )
LOG ON
( NAME = 'Test_log',
FILENAME = 'c:\Test.ldf',
SIZE = 5MB,
MAXSIZE = 25MB,
FILEGROWTH = 5MB )
GO
--add device
EXEC master.dbo.sp_addumpdevice 'disk', 'mydiskdump', 'c:\dump.bak'
GO
CREATE TABLE Test.dbo.tblTest (
col1 char(1)
)
GO
delete Test.dbo.tblTest
insert into Test.dbo.tblTest values ('a')
GO
--whole backup 1
BACKUP DATABASE Test TO mydiskdump
GO
delete Test.dbo.tblTest
insert into Test.dbo.tblTest values('b')
GO
--differential backup 1
BACKUP DATABASE Test
TO mydiskdump
WITH DIFFERENTIAL
GO
--whole backup 2
BACKUP DATABASE Test TO mydiskdump
GO
delete Test.dbo.tblTest
insert into Test.dbo.tblTest values('c')
GO
--differential backup 2
BACKUP DATABASE Test
TO mydiskdump
WITH DIFFERENTIAL
GO
delete Test.dbo.tblTest
insert into Test.dbo.tblTest values('d')
GO
--whole backup 3
BACKUP DATABASE Test TO mydiskdump
go
restore headeronly from mydiskdump
go
restore database Test from mydiskdump with file = 1, recovery
select * from Test.dbo.tblTest
restore database Test from mydiskdump with file = 1, norecovery
restore database Test from mydiskdump with file = 2, recovery
select * from Test.dbo.tblTest
restore database Test from mydiskdump with file = 3, norecovery
restore database Test from mydiskdump with file = 4, recovery
select * from Test.dbo.tblTest
restore database Test from mydiskdump with file = 5, recovery
select * from Test.dbo.tblTest
go
Note that dump devices can store multiple backup sets. You can get the
backup sets that a dump device contains using the restore headeronly command
which lets you know which backup sets to restore. I'd suggest you consider
naming your backup sets though as this can help work out which backups to
restore as well..
HTH
Regards,
Greg Linwood
SQL Server MVP
"haode" <haode@.hao.com> wrote in message
news:%23eNTtec9DHA.1504@.TK2MSFTNGP12.phx.gbl...
> --Drop database
> if exists (select * from master.dbo.sysdatabases where name='Test')
> drop database Test
> GO
> --Drop device
> if exists (select * from master.dbo.sysdevices where name='mydiskdump')
> exec master.dbo.sp_dropdevice mydiskdump
> GO
> --Create Test database
> CREATE DATABASE Test
> ON
> ( NAME = Test_dat,
> FILENAME = 'c:\Test.mdf',
> SIZE = 5,
> MAXSIZE = 50,
> FILEGROWTH = 5 )
> LOG ON
> ( NAME = 'Test_log',
> FILENAME = 'c:\Test.ldf',
> SIZE = 5MB,
> MAXSIZE = 25MB,
> FILEGROWTH = 5MB )
> GO
> --add device
> EXEC master.dbo.sp_addumpdevice 'disk', 'mydiskdump', 'c:\dump.bak'
> GO
> CREATE TABLE Test.dbo.tblTest (
> col1 char(1)
> )
> GO
> delete Test.dbo.tblTest values
> insert into Test.dbo.tblTest values ('a')
> GO
> --whole backup 1
> BACKUP DATABASE Test TO mydiskdump
> GO
> delete Test.dbo.tblTest values
> insert into Test.dbo.tblTest values('b')
> GO
> --differential backup 1
> BACKUP DATABASE Test
> TO mydiskdump
> WITH DIFFERENTIAL
> GO
> --whole backup 2
> BACKUP DATABASE Test TO mydiskdump
> GO
> delete Test.dbo.tblTest values
> insert into Test.dbo.tblTest values('c')
> GO
> --differential backup 2
> BACKUP DATABASE Test
> TO mydiskdump
> WITH DIFFERENTIAL
> GO
> delete Test.dbo.tblTest values
> insert into Test.dbo.tblTest values('d')
> GO
> Am I correct in creating the database and the way of backup?
> Would you teach me the senarios that restore the database to
'a','b','c','d'
> states?
> Thanks in advance.
>
restore databases in T-SQL.
--Drop database
if exists (select * from master.dbo.sysdatabases where name='Test')
drop database Test
GO
--Drop device
if exists (select * from master.dbo.sysdevices where name='mydiskdump')
exec master.dbo.sp_dropdevice mydiskdump
GO
--Create Test database
CREATE DATABASE Test
ON
( NAME = Test_dat,
FILENAME = 'c:\Test.mdf',
SIZE = 5,
MAXSIZE = 50,
FILEGROWTH = 5 )
LOG ON
( NAME = 'Test_log',
FILENAME = 'c:\Test.ldf',
SIZE = 5MB,
MAXSIZE = 25MB,
FILEGROWTH = 5MB )
GO
--add device
EXEC master.dbo.sp_addumpdevice 'disk', 'mydiskdump', 'c:\dump.bak'
GO
CREATE TABLE Test.dbo.tblTest (
col1 char(1)
)
GO
delete Test.dbo.tblTest values
insert into Test.dbo.tblTest values ('a')
GO
--whole backup 1
BACKUP DATABASE Test TO mydiskdump
GO
delete Test.dbo.tblTest values
insert into Test.dbo.tblTest values('b')
GO
--differential backup 1
BACKUP DATABASE Test
TO mydiskdump
WITH DIFFERENTIAL
GO
--whole backup 2
BACKUP DATABASE Test TO mydiskdump
GO
delete Test.dbo.tblTest values
insert into Test.dbo.tblTest values('c')
GO
--differential backup 2
BACKUP DATABASE Test
TO mydiskdump
WITH DIFFERENTIAL
GO
delete Test.dbo.tblTest values
insert into Test.dbo.tblTest values('d')
GO
Am I correct in creating the database and the way of backup?
Would you teach me the senarios that restore the database to 'a','b','c','d'
states?
Thanks in advance.You'll need to add another backup to backup 'd', but something like this
should do:
--Drop database
if exists (select * from master.dbo.sysdatabases where name='Test')
drop database Test
GO
--Drop device
if exists (select * from master.dbo.sysdevices where name='mydiskdump')
exec master.dbo.sp_dropdevice mydiskdump
GO
--Create Test database
CREATE DATABASE Test
ON
( NAME = Test_dat,
FILENAME = 'c:\Test.mdf',
SIZE = 5,
MAXSIZE = 50,
FILEGROWTH = 5 )
LOG ON
( NAME = 'Test_log',
FILENAME = 'c:\Test.ldf',
SIZE = 5MB,
MAXSIZE = 25MB,
FILEGROWTH = 5MB )
GO
--add device
EXEC master.dbo.sp_addumpdevice 'disk', 'mydiskdump', 'c:\dump.bak'
GO
CREATE TABLE Test.dbo.tblTest (
col1 char(1)
)
GO
delete Test.dbo.tblTest
insert into Test.dbo.tblTest values ('a')
GO
--whole backup 1
BACKUP DATABASE Test TO mydiskdump
GO
delete Test.dbo.tblTest
insert into Test.dbo.tblTest values('b')
GO
--differential backup 1
BACKUP DATABASE Test
TO mydiskdump
WITH DIFFERENTIAL
GO
--whole backup 2
BACKUP DATABASE Test TO mydiskdump
GO
delete Test.dbo.tblTest
insert into Test.dbo.tblTest values('c')
GO
--differential backup 2
BACKUP DATABASE Test
TO mydiskdump
WITH DIFFERENTIAL
GO
delete Test.dbo.tblTest
insert into Test.dbo.tblTest values('d')
GO
--whole backup 3
BACKUP DATABASE Test TO mydiskdump
go
restore headeronly from mydiskdump
go
restore database Test from mydiskdump with file = 1, recovery
select * from Test.dbo.tblTest
restore database Test from mydiskdump with file = 1, norecovery
restore database Test from mydiskdump with file = 2, recovery
select * from Test.dbo.tblTest
restore database Test from mydiskdump with file = 3, norecovery
restore database Test from mydiskdump with file = 4, recovery
select * from Test.dbo.tblTest
restore database Test from mydiskdump with file = 5, recovery
select * from Test.dbo.tblTest
go
Note that dump devices can store multiple backup sets. You can get the
backup sets that a dump device contains using the restore headeronly command
which lets you know which backup sets to restore. I'd suggest you consider
naming your backup sets though as this can help work out which backups to
restore as well..
HTH
Regards,
Greg Linwood
SQL Server MVP
"haode" <haode@.hao.com> wrote in message
news:%23eNTtec9DHA.1504@.TK2MSFTNGP12.phx.gbl...
> --Drop database
> if exists (select * from master.dbo.sysdatabases where name='Test')
> drop database Test
> GO
> --Drop device
> if exists (select * from master.dbo.sysdevices where name='mydiskdump')
> exec master.dbo.sp_dropdevice mydiskdump
> GO
> --Create Test database
> CREATE DATABASE Test
> ON
> ( NAME = Test_dat,
> FILENAME = 'c:\Test.mdf',
> SIZE = 5,
> MAXSIZE = 50,
> FILEGROWTH = 5 )
> LOG ON
> ( NAME = 'Test_log',
> FILENAME = 'c:\Test.ldf',
> SIZE = 5MB,
> MAXSIZE = 25MB,
> FILEGROWTH = 5MB )
> GO
> --add device
> EXEC master.dbo.sp_addumpdevice 'disk', 'mydiskdump', 'c:\dump.bak'
> GO
> CREATE TABLE Test.dbo.tblTest (
> col1 char(1)
> )
> GO
> delete Test.dbo.tblTest values
> insert into Test.dbo.tblTest values ('a')
> GO
> --whole backup 1
> BACKUP DATABASE Test TO mydiskdump
> GO
> delete Test.dbo.tblTest values
> insert into Test.dbo.tblTest values('b')
> GO
> --differential backup 1
> BACKUP DATABASE Test
> TO mydiskdump
> WITH DIFFERENTIAL
> GO
> --whole backup 2
> BACKUP DATABASE Test TO mydiskdump
> GO
> delete Test.dbo.tblTest values
> insert into Test.dbo.tblTest values('c')
> GO
> --differential backup 2
> BACKUP DATABASE Test
> TO mydiskdump
> WITH DIFFERENTIAL
> GO
> delete Test.dbo.tblTest values
> insert into Test.dbo.tblTest values('d')
> GO
> Am I correct in creating the database and the way of backup?
> Would you teach me the senarios that restore the database to
'a','b','c','d'
> states?
> Thanks in advance.
>sql
if exists (select * from master.dbo.sysdatabases where name='Test')
drop database Test
GO
--Drop device
if exists (select * from master.dbo.sysdevices where name='mydiskdump')
exec master.dbo.sp_dropdevice mydiskdump
GO
--Create Test database
CREATE DATABASE Test
ON
( NAME = Test_dat,
FILENAME = 'c:\Test.mdf',
SIZE = 5,
MAXSIZE = 50,
FILEGROWTH = 5 )
LOG ON
( NAME = 'Test_log',
FILENAME = 'c:\Test.ldf',
SIZE = 5MB,
MAXSIZE = 25MB,
FILEGROWTH = 5MB )
GO
--add device
EXEC master.dbo.sp_addumpdevice 'disk', 'mydiskdump', 'c:\dump.bak'
GO
CREATE TABLE Test.dbo.tblTest (
col1 char(1)
)
GO
delete Test.dbo.tblTest values
insert into Test.dbo.tblTest values ('a')
GO
--whole backup 1
BACKUP DATABASE Test TO mydiskdump
GO
delete Test.dbo.tblTest values
insert into Test.dbo.tblTest values('b')
GO
--differential backup 1
BACKUP DATABASE Test
TO mydiskdump
WITH DIFFERENTIAL
GO
--whole backup 2
BACKUP DATABASE Test TO mydiskdump
GO
delete Test.dbo.tblTest values
insert into Test.dbo.tblTest values('c')
GO
--differential backup 2
BACKUP DATABASE Test
TO mydiskdump
WITH DIFFERENTIAL
GO
delete Test.dbo.tblTest values
insert into Test.dbo.tblTest values('d')
GO
Am I correct in creating the database and the way of backup?
Would you teach me the senarios that restore the database to 'a','b','c','d'
states?
Thanks in advance.You'll need to add another backup to backup 'd', but something like this
should do:
--Drop database
if exists (select * from master.dbo.sysdatabases where name='Test')
drop database Test
GO
--Drop device
if exists (select * from master.dbo.sysdevices where name='mydiskdump')
exec master.dbo.sp_dropdevice mydiskdump
GO
--Create Test database
CREATE DATABASE Test
ON
( NAME = Test_dat,
FILENAME = 'c:\Test.mdf',
SIZE = 5,
MAXSIZE = 50,
FILEGROWTH = 5 )
LOG ON
( NAME = 'Test_log',
FILENAME = 'c:\Test.ldf',
SIZE = 5MB,
MAXSIZE = 25MB,
FILEGROWTH = 5MB )
GO
--add device
EXEC master.dbo.sp_addumpdevice 'disk', 'mydiskdump', 'c:\dump.bak'
GO
CREATE TABLE Test.dbo.tblTest (
col1 char(1)
)
GO
delete Test.dbo.tblTest
insert into Test.dbo.tblTest values ('a')
GO
--whole backup 1
BACKUP DATABASE Test TO mydiskdump
GO
delete Test.dbo.tblTest
insert into Test.dbo.tblTest values('b')
GO
--differential backup 1
BACKUP DATABASE Test
TO mydiskdump
WITH DIFFERENTIAL
GO
--whole backup 2
BACKUP DATABASE Test TO mydiskdump
GO
delete Test.dbo.tblTest
insert into Test.dbo.tblTest values('c')
GO
--differential backup 2
BACKUP DATABASE Test
TO mydiskdump
WITH DIFFERENTIAL
GO
delete Test.dbo.tblTest
insert into Test.dbo.tblTest values('d')
GO
--whole backup 3
BACKUP DATABASE Test TO mydiskdump
go
restore headeronly from mydiskdump
go
restore database Test from mydiskdump with file = 1, recovery
select * from Test.dbo.tblTest
restore database Test from mydiskdump with file = 1, norecovery
restore database Test from mydiskdump with file = 2, recovery
select * from Test.dbo.tblTest
restore database Test from mydiskdump with file = 3, norecovery
restore database Test from mydiskdump with file = 4, recovery
select * from Test.dbo.tblTest
restore database Test from mydiskdump with file = 5, recovery
select * from Test.dbo.tblTest
go
Note that dump devices can store multiple backup sets. You can get the
backup sets that a dump device contains using the restore headeronly command
which lets you know which backup sets to restore. I'd suggest you consider
naming your backup sets though as this can help work out which backups to
restore as well..
HTH
Regards,
Greg Linwood
SQL Server MVP
"haode" <haode@.hao.com> wrote in message
news:%23eNTtec9DHA.1504@.TK2MSFTNGP12.phx.gbl...
> --Drop database
> if exists (select * from master.dbo.sysdatabases where name='Test')
> drop database Test
> GO
> --Drop device
> if exists (select * from master.dbo.sysdevices where name='mydiskdump')
> exec master.dbo.sp_dropdevice mydiskdump
> GO
> --Create Test database
> CREATE DATABASE Test
> ON
> ( NAME = Test_dat,
> FILENAME = 'c:\Test.mdf',
> SIZE = 5,
> MAXSIZE = 50,
> FILEGROWTH = 5 )
> LOG ON
> ( NAME = 'Test_log',
> FILENAME = 'c:\Test.ldf',
> SIZE = 5MB,
> MAXSIZE = 25MB,
> FILEGROWTH = 5MB )
> GO
> --add device
> EXEC master.dbo.sp_addumpdevice 'disk', 'mydiskdump', 'c:\dump.bak'
> GO
> CREATE TABLE Test.dbo.tblTest (
> col1 char(1)
> )
> GO
> delete Test.dbo.tblTest values
> insert into Test.dbo.tblTest values ('a')
> GO
> --whole backup 1
> BACKUP DATABASE Test TO mydiskdump
> GO
> delete Test.dbo.tblTest values
> insert into Test.dbo.tblTest values('b')
> GO
> --differential backup 1
> BACKUP DATABASE Test
> TO mydiskdump
> WITH DIFFERENTIAL
> GO
> --whole backup 2
> BACKUP DATABASE Test TO mydiskdump
> GO
> delete Test.dbo.tblTest values
> insert into Test.dbo.tblTest values('c')
> GO
> --differential backup 2
> BACKUP DATABASE Test
> TO mydiskdump
> WITH DIFFERENTIAL
> GO
> delete Test.dbo.tblTest values
> insert into Test.dbo.tblTest values('d')
> GO
> Am I correct in creating the database and the way of backup?
> Would you teach me the senarios that restore the database to
'a','b','c','d'
> states?
> Thanks in advance.
>sql
Subscribe to:
Posts (Atom)