Is there anyway I can restore a database without having to provide a
database name in the restore command? I have a utility that I wrote
to restore my database, but right now I hardcode the database name
into the restore command. Is it possible for the restore command to
just figure out the name of the database on its own so I don't have to
provide it? I'd like my utility to be able to restore databases with
different names and I don't want to have to prompt the user to enter
one.
Any suggestions?Check out the following commands:
RESTORE HEADERONLY FROM DISK =3D 'x:\foo.bak'
RESTORE FILELISTONLY FROM DISK =3D 'x:\foo.bak'
You will see a column named DatabaseName is returned from the first =statement. This is the name of the database that was backed up.
What if the user does not want to overwrite their database? What if =they want to perform the restore as a new name so that they can compare =their current version of foo to the previous version of foo (that they =restore as Oldfoo)?
-- Keith
"Ray Lavelle" <bostonpartykid@.yahoo.com> wrote in message =news:d8653140.0405201136.11fd6bc3@.posting.google.com...
> Is there anyway I can restore a database without having to provide a
> database name in the restore command? I have a utility that I wrote
> to restore my database, but right now I hardcode the database name
> into the restore command. Is it possible for the restore command to
> just figure out the name of the database on its own so I don't have to
> provide it? I'd like my utility to be able to restore databases with
> different names and I don't want to have to prompt the user to enter
> one.
> Any suggestions?|||Thanks, this is exactly what I was looking for!
To answer your question, my application uses a fixed database name so
it has to be restored with the same name as it was backed up with or
my program won't even recognize it. I'm now adding a couple more
databases to support new additions to the product so I need to be able
to back those up also.
"Keith Kratochvil" <sqlguy.back2u@.comcast.net> wrote in message news:<#b#NLKqPEHA.3988@.tk2msftngp13.phx.gbl>...
> Check out the following commands:
> RESTORE HEADERONLY FROM DISK = 'x:\foo.bak'
> RESTORE FILELISTONLY FROM DISK = 'x:\foo.bak'
> You will see a column named DatabaseName is returned from the first
> statement. This is the name of the database that was backed up.
>
> What if the user does not want to overwrite their database? What if
> they want to perform the restore as a new name so that they can compare
> their current version of foo to the previous version of foo (that they
> restore as Oldfoo)?
> --
> Keith
>
> "Ray Lavelle" <bostonpartykid@.yahoo.com> wrote in message
> news:d8653140.0405201136.11fd6bc3@.posting.google.com...
> > Is there anyway I can restore a database without having to provide a
> > database name in the restore command? I have a utility that I wrote
> > to restore my database, but right now I hardcode the database name
> > into the restore command. Is it possible for the restore command to
> > just figure out the name of the database on its own so I don't have to
> > provide it? I'd like my utility to be able to restore databases with
> > different names and I don't want to have to prompt the user to enter
> > one.
> > Any suggestions?sql
Showing posts with label provide. Show all posts
Showing posts with label provide. Show all posts
Monday, March 26, 2012
Restore database without providing a name?/
Is there anyway I can restore a database without having to provide a
database name in the restore command? I have a utility that I wrote
to restore my database, but right now I hardcode the database name
into the restore command. Is it possible for the restore command to
just figure out the name of the database on its own so I don't have to
provide it? I'd like my utility to be able to restore databases with
different names and I don't want to have to prompt the user to enter
one.
Any suggestions?
Check out the following commands:
RESTORE HEADERONLY FROM DISK =3D 'x:\foo.bak'
RESTORE FILELISTONLY FROM DISK =3D 'x:\foo.bak'
You will see a column named DatabaseName is returned from the first =
statement. This is the name of the database that was backed up. =20
What if the user does not want to overwrite their database? What if =
they want to perform the restore as a new name so that they can compare =
their current version of foo to the previous version of foo (that they =
restore as Oldfoo)?
--=20
Keith
"Ray Lavelle" <bostonpartykid@.yahoo.com> wrote in message =
news:d8653140.0405201136.11fd6bc3@.posting.google.c om...
> Is there anyway I can restore a database without having to provide a
> database name in the restore command? I have a utility that I wrote
> to restore my database, but right now I hardcode the database name
> into the restore command. Is it possible for the restore command to
> just figure out the name of the database on its own so I don't have to
> provide it? I'd like my utility to be able to restore databases with
> different names and I don't want to have to prompt the user to enter
> one.
> Any suggestions?
|||Thanks, this is exactly what I was looking for!
To answer your question, my application uses a fixed database name so
it has to be restored with the same name as it was backed up with or
my program won't even recognize it. I'm now adding a couple more
databases to support new additions to the product so I need to be able
to back those up also.
"Keith Kratochvil" <sqlguy.back2u@.comcast.net> wrote in message news:<#b#NLKqPEHA.3988@.tk2msftngp13.phx.gbl>...[vbcol=seagreen]
> Check out the following commands:
> RESTORE HEADERONLY FROM DISK = 'x:\foo.bak'
> RESTORE FILELISTONLY FROM DISK = 'x:\foo.bak'
> You will see a column named DatabaseName is returned from the first
> statement. This is the name of the database that was backed up.
>
> What if the user does not want to overwrite their database? What if
> they want to perform the restore as a new name so that they can compare
> their current version of foo to the previous version of foo (that they
> restore as Oldfoo)?
> --
> Keith
>
> "Ray Lavelle" <bostonpartykid@.yahoo.com> wrote in message
> news:d8653140.0405201136.11fd6bc3@.posting.google.c om...
database name in the restore command? I have a utility that I wrote
to restore my database, but right now I hardcode the database name
into the restore command. Is it possible for the restore command to
just figure out the name of the database on its own so I don't have to
provide it? I'd like my utility to be able to restore databases with
different names and I don't want to have to prompt the user to enter
one.
Any suggestions?
Check out the following commands:
RESTORE HEADERONLY FROM DISK =3D 'x:\foo.bak'
RESTORE FILELISTONLY FROM DISK =3D 'x:\foo.bak'
You will see a column named DatabaseName is returned from the first =
statement. This is the name of the database that was backed up. =20
What if the user does not want to overwrite their database? What if =
they want to perform the restore as a new name so that they can compare =
their current version of foo to the previous version of foo (that they =
restore as Oldfoo)?
--=20
Keith
"Ray Lavelle" <bostonpartykid@.yahoo.com> wrote in message =
news:d8653140.0405201136.11fd6bc3@.posting.google.c om...
> Is there anyway I can restore a database without having to provide a
> database name in the restore command? I have a utility that I wrote
> to restore my database, but right now I hardcode the database name
> into the restore command. Is it possible for the restore command to
> just figure out the name of the database on its own so I don't have to
> provide it? I'd like my utility to be able to restore databases with
> different names and I don't want to have to prompt the user to enter
> one.
> Any suggestions?
|||Thanks, this is exactly what I was looking for!
To answer your question, my application uses a fixed database name so
it has to be restored with the same name as it was backed up with or
my program won't even recognize it. I'm now adding a couple more
databases to support new additions to the product so I need to be able
to back those up also.
"Keith Kratochvil" <sqlguy.back2u@.comcast.net> wrote in message news:<#b#NLKqPEHA.3988@.tk2msftngp13.phx.gbl>...[vbcol=seagreen]
> Check out the following commands:
> RESTORE HEADERONLY FROM DISK = 'x:\foo.bak'
> RESTORE FILELISTONLY FROM DISK = 'x:\foo.bak'
> You will see a column named DatabaseName is returned from the first
> statement. This is the name of the database that was backed up.
>
> What if the user does not want to overwrite their database? What if
> they want to perform the restore as a new name so that they can compare
> their current version of foo to the previous version of foo (that they
> restore as Oldfoo)?
> --
> Keith
>
> "Ray Lavelle" <bostonpartykid@.yahoo.com> wrote in message
> news:d8653140.0405201136.11fd6bc3@.posting.google.c om...
Restore database without providing a name?/
Is there anyway I can restore a database without having to provide a
database name in the restore command? I have a utility that I wrote
to restore my database, but right now I hardcode the database name
into the restore command. Is it possible for the restore command to
just figure out the name of the database on its own so I don't have to
provide it? I'd like my utility to be able to restore databases with
different names and I don't want to have to prompt the user to enter
one.
Any suggestions?Check out the following commands:
RESTORE HEADERONLY FROM DISK =3D 'x:\foo.bak'
RESTORE FILELISTONLY FROM DISK =3D 'x:\foo.bak'
You will see a column named DatabaseName is returned from the first =
statement. This is the name of the database that was backed up. =20
What if the user does not want to overwrite their database? What if =
they want to perform the restore as a new name so that they can compare =
their current version of foo to the previous version of foo (that they =
restore as Oldfoo)?
--=20
Keith
"Ray Lavelle" <bostonpartykid@.yahoo.com> wrote in message =
news:d8653140.0405201136.11fd6bc3@.posting.google.com...
> Is there anyway I can restore a database without having to provide a
> database name in the restore command? I have a utility that I wrote
> to restore my database, but right now I hardcode the database name
> into the restore command. Is it possible for the restore command to
> just figure out the name of the database on its own so I don't have to
> provide it? I'd like my utility to be able to restore databases with
> different names and I don't want to have to prompt the user to enter
> one.
> Any suggestions?|||Thanks, this is exactly what I was looking for!
To answer your question, my application uses a fixed database name so
it has to be restored with the same name as it was backed up with or
my program won't even recognize it. I'm now adding a couple more
databases to support new additions to the product so I need to be able
to back those up also.
"Keith Kratochvil" <sqlguy.back2u@.comcast.net> wrote in message news:<#b#NLKqPEHA.3988@.tk2ms
ftngp13.phx.gbl>...[vbcol=seagreen]
> Check out the following commands:
> RESTORE HEADERONLY FROM DISK = 'x:\foo.bak'
> RESTORE FILELISTONLY FROM DISK = 'x:\foo.bak'
> You will see a column named DatabaseName is returned from the first
> statement. This is the name of the database that was backed up.
>
> What if the user does not want to overwrite their database? What if
> they want to perform the restore as a new name so that they can compare
> their current version of foo to the previous version of foo (that they
> restore as Oldfoo)?
> --
> Keith
>
> "Ray Lavelle" <bostonpartykid@.yahoo.com> wrote in message
> news:d8653140.0405201136.11fd6bc3@.posting.google.com...
database name in the restore command? I have a utility that I wrote
to restore my database, but right now I hardcode the database name
into the restore command. Is it possible for the restore command to
just figure out the name of the database on its own so I don't have to
provide it? I'd like my utility to be able to restore databases with
different names and I don't want to have to prompt the user to enter
one.
Any suggestions?Check out the following commands:
RESTORE HEADERONLY FROM DISK =3D 'x:\foo.bak'
RESTORE FILELISTONLY FROM DISK =3D 'x:\foo.bak'
You will see a column named DatabaseName is returned from the first =
statement. This is the name of the database that was backed up. =20
What if the user does not want to overwrite their database? What if =
they want to perform the restore as a new name so that they can compare =
their current version of foo to the previous version of foo (that they =
restore as Oldfoo)?
--=20
Keith
"Ray Lavelle" <bostonpartykid@.yahoo.com> wrote in message =
news:d8653140.0405201136.11fd6bc3@.posting.google.com...
> Is there anyway I can restore a database without having to provide a
> database name in the restore command? I have a utility that I wrote
> to restore my database, but right now I hardcode the database name
> into the restore command. Is it possible for the restore command to
> just figure out the name of the database on its own so I don't have to
> provide it? I'd like my utility to be able to restore databases with
> different names and I don't want to have to prompt the user to enter
> one.
> Any suggestions?|||Thanks, this is exactly what I was looking for!
To answer your question, my application uses a fixed database name so
it has to be restored with the same name as it was backed up with or
my program won't even recognize it. I'm now adding a couple more
databases to support new additions to the product so I need to be able
to back those up also.
"Keith Kratochvil" <sqlguy.back2u@.comcast.net> wrote in message news:<#b#NLKqPEHA.3988@.tk2ms
ftngp13.phx.gbl>...[vbcol=seagreen]
> Check out the following commands:
> RESTORE HEADERONLY FROM DISK = 'x:\foo.bak'
> RESTORE FILELISTONLY FROM DISK = 'x:\foo.bak'
> You will see a column named DatabaseName is returned from the first
> statement. This is the name of the database that was backed up.
>
> What if the user does not want to overwrite their database? What if
> they want to perform the restore as a new name so that they can compare
> their current version of foo to the previous version of foo (that they
> restore as Oldfoo)?
> --
> Keith
>
> "Ray Lavelle" <bostonpartykid@.yahoo.com> wrote in message
> news:d8653140.0405201136.11fd6bc3@.posting.google.com...
Wednesday, March 21, 2012
Restore database from a backup and specify a new log file name
Hi All,
I am trying to restore a database from a bak file and looking out for a way
if we can provide a new log file name while trying to restore. (I dont have
enought space on drive to accomodate the .ldf file existing in the bak file)
.
Thanks in advance..
ManojYou can use the move option. Check BOL for restore database for more
details.
Adi
On Feb 5, 9:55 pm, xyz <x...@.discussions.microsoft.com> wrote:
> Hi All,
> I am trying to restore a database from a bak file and looking out for a wa
y
> if we can provide a new log file name while trying to restore. (I dont hav
e
> enought space on drive to accomodate the .ldf file existing in the bak fil
e).
> Thanks in advance..
> Manoj|||Hello,
We can give new path and new file name along with RESTORE DATABASE command.
RESTORE DATABASE <dbname> FROM Disk='D:\backup\dbname.bak'
With Move 'logical_mdf_name' to 'D:\mssql\dbname.mdf',
Move 'Logical_ldf_name' to 'K:\mssql\dbname_log.ldf', stats=5
Phisical file name and path can be chnaged based on your requirement.
Thanks
Hari
"xyz" <xyz@.discussions.microsoft.com> wrote in message
news:8CB7CFD5-1462-4E01-90EA-3FAC07A43302@.microsoft.com...
> Hi All,
> I am trying to restore a database from a bak file and looking out for a
> way
> if we can provide a new log file name while trying to restore. (I dont
> have
> enought space on drive to accomodate the .ldf file existing in the bak
> file).
> Thanks in advance..
> Manoj
I am trying to restore a database from a bak file and looking out for a way
if we can provide a new log file name while trying to restore. (I dont have
enought space on drive to accomodate the .ldf file existing in the bak file)
.
Thanks in advance..
ManojYou can use the move option. Check BOL for restore database for more
details.
Adi
On Feb 5, 9:55 pm, xyz <x...@.discussions.microsoft.com> wrote:
> Hi All,
> I am trying to restore a database from a bak file and looking out for a wa
y
> if we can provide a new log file name while trying to restore. (I dont hav
e
> enought space on drive to accomodate the .ldf file existing in the bak fil
e).
> Thanks in advance..
> Manoj|||Hello,
We can give new path and new file name along with RESTORE DATABASE command.
RESTORE DATABASE <dbname> FROM Disk='D:\backup\dbname.bak'
With Move 'logical_mdf_name' to 'D:\mssql\dbname.mdf',
Move 'Logical_ldf_name' to 'K:\mssql\dbname_log.ldf', stats=5
Phisical file name and path can be chnaged based on your requirement.
Thanks
Hari
"xyz" <xyz@.discussions.microsoft.com> wrote in message
news:8CB7CFD5-1462-4E01-90EA-3FAC07A43302@.microsoft.com...
> Hi All,
> I am trying to restore a database from a bak file and looking out for a
> way
> if we can provide a new log file name while trying to restore. (I dont
> have
> enought space on drive to accomodate the .ldf file existing in the bak
> file).
> Thanks in advance..
> Manoj
Restore database from a backup and specify a new log file name
Hi All,
I am trying to restore a database from a bak file and looking out for a way
if we can provide a new log file name while trying to restore. (I dont have
enought space on drive to accomodate the .ldf file existing in the bak file).
Thanks in advance..
Manoj
You can use the move option. Check BOL for restore database for more
details.
Adi
On Feb 5, 9:55 pm, xyz <x...@.discussions.microsoft.com> wrote:
> Hi All,
> I am trying to restore a database from a bak file and looking out for a way
> if we can provide a new log file name while trying to restore. (I dont have
> enought space on drive to accomodate the .ldf file existing in the bak file).
> Thanks in advance..
> Manoj
|||Hello,
We can give new path and new file name along with RESTORE DATABASE command.
RESTORE DATABASE <dbname> FROM Disk='D:\backup\dbname.bak'
With Move 'logical_mdf_name' to 'D:\mssql\dbname.mdf',
Move 'Logical_ldf_name' to 'K:\mssql\dbname_log.ldf', stats=5
Phisical file name and path can be chnaged based on your requirement.
Thanks
Hari
"xyz" <xyz@.discussions.microsoft.com> wrote in message
news:8CB7CFD5-1462-4E01-90EA-3FAC07A43302@.microsoft.com...
> Hi All,
> I am trying to restore a database from a bak file and looking out for a
> way
> if we can provide a new log file name while trying to restore. (I dont
> have
> enought space on drive to accomodate the .ldf file existing in the bak
> file).
> Thanks in advance..
> Manoj
I am trying to restore a database from a bak file and looking out for a way
if we can provide a new log file name while trying to restore. (I dont have
enought space on drive to accomodate the .ldf file existing in the bak file).
Thanks in advance..
Manoj
You can use the move option. Check BOL for restore database for more
details.
Adi
On Feb 5, 9:55 pm, xyz <x...@.discussions.microsoft.com> wrote:
> Hi All,
> I am trying to restore a database from a bak file and looking out for a way
> if we can provide a new log file name while trying to restore. (I dont have
> enought space on drive to accomodate the .ldf file existing in the bak file).
> Thanks in advance..
> Manoj
|||Hello,
We can give new path and new file name along with RESTORE DATABASE command.
RESTORE DATABASE <dbname> FROM Disk='D:\backup\dbname.bak'
With Move 'logical_mdf_name' to 'D:\mssql\dbname.mdf',
Move 'Logical_ldf_name' to 'K:\mssql\dbname_log.ldf', stats=5
Phisical file name and path can be chnaged based on your requirement.
Thanks
Hari
"xyz" <xyz@.discussions.microsoft.com> wrote in message
news:8CB7CFD5-1462-4E01-90EA-3FAC07A43302@.microsoft.com...
> Hi All,
> I am trying to restore a database from a bak file and looking out for a
> way
> if we can provide a new log file name while trying to restore. (I dont
> have
> enought space on drive to accomodate the .ldf file existing in the bak
> file).
> Thanks in advance..
> Manoj
Restore database from a backup and specify a new log file name
Hi All,
I am trying to restore a database from a bak file and looking out for a way
if we can provide a new log file name while trying to restore. (I dont have
enought space on drive to accomodate the .ldf file existing in the bak file).
Thanks in advance..
ManojYou can use the move option. Check BOL for restore database for more
details.
Adi
On Feb 5, 9:55 pm, xyz <x...@.discussions.microsoft.com> wrote:
> Hi All,
> I am trying to restore a database from a bak file and looking out for a way
> if we can provide a new log file name while trying to restore. (I dont have
> enought space on drive to accomodate the .ldf file existing in the bak file).
> Thanks in advance..
> Manoj|||Hello,
We can give new path and new file name along with RESTORE DATABASE command.
RESTORE DATABASE <dbname> FROM Disk='D:\backup\dbname.bak'
With Move 'logical_mdf_name' to 'D:\mssql\dbname.mdf',
Move 'Logical_ldf_name' to 'K:\mssql\dbname_log.ldf', stats=5
Phisical file name and path can be chnaged based on your requirement.
Thanks
Hari
"xyz" <xyz@.discussions.microsoft.com> wrote in message
news:8CB7CFD5-1462-4E01-90EA-3FAC07A43302@.microsoft.com...
> Hi All,
> I am trying to restore a database from a bak file and looking out for a
> way
> if we can provide a new log file name while trying to restore. (I dont
> have
> enought space on drive to accomodate the .ldf file existing in the bak
> file).
> Thanks in advance..
> Manojsql
I am trying to restore a database from a bak file and looking out for a way
if we can provide a new log file name while trying to restore. (I dont have
enought space on drive to accomodate the .ldf file existing in the bak file).
Thanks in advance..
ManojYou can use the move option. Check BOL for restore database for more
details.
Adi
On Feb 5, 9:55 pm, xyz <x...@.discussions.microsoft.com> wrote:
> Hi All,
> I am trying to restore a database from a bak file and looking out for a way
> if we can provide a new log file name while trying to restore. (I dont have
> enought space on drive to accomodate the .ldf file existing in the bak file).
> Thanks in advance..
> Manoj|||Hello,
We can give new path and new file name along with RESTORE DATABASE command.
RESTORE DATABASE <dbname> FROM Disk='D:\backup\dbname.bak'
With Move 'logical_mdf_name' to 'D:\mssql\dbname.mdf',
Move 'Logical_ldf_name' to 'K:\mssql\dbname_log.ldf', stats=5
Phisical file name and path can be chnaged based on your requirement.
Thanks
Hari
"xyz" <xyz@.discussions.microsoft.com> wrote in message
news:8CB7CFD5-1462-4E01-90EA-3FAC07A43302@.microsoft.com...
> Hi All,
> I am trying to restore a database from a bak file and looking out for a
> way
> if we can provide a new log file name while trying to restore. (I dont
> have
> enought space on drive to accomodate the .ldf file existing in the bak
> file).
> Thanks in advance..
> Manojsql
Subscribe to:
Posts (Atom)