Home All Groups Group Topic Archive Search About


Author
23 Oct 2007 7:01 AM
denverdude
Any ideas on scripting an SQL database to overwrite another SQL database (in
SQL2005Express??)

I've got:
RESTORE DATABASE <name>
FROM DISK =
‘C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Backup\<name>.bak

Is there something I'm missing?

--
denverdude in OZ

Author
23 Oct 2007 3:12 PM
urkec
"denverdude" wrote:

> Any ideas on scripting an SQL database to overwrite another SQL database (in
> SQL2005Express??)
>
> I've got:
> RESTORE DATABASE <name>
> FROM DISK =
> ‘C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Backup\<name>.bak
>
> Is there something I'm missing?
>

Wrong group probably, you should post in a SQL Server group. From command
line you could use sqlcmd:


sqlcmd -S "ServerName" -E -Q "RESTORE DATABASE myDatabase FROM DISK =
'c:\microsoft sql server\MSSQL.1\MSSQL\Backup\myDatabase.bak'"

-S - Server name
-E - Use trusted connection
-Q - Query string

--
urkec
Author
24 Oct 2007 5:58 AM
TRISHtheWISH
Can you not detach the previous database, and then it should not be
recognized unless you re attach?

Show quote
"denverdude" wrote:

> Any ideas on scripting an SQL database to overwrite another SQL database (in
> SQL2005Express??)
>
> I've got:
> RESTORE DATABASE <name>
> FROM DISK =
> ‘C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Backup\<name>.bak
>
> Is there something I'm missing?
>
> --
> denverdude in OZ
Author
24 Oct 2007 6:58 AM
TRISHtheWISH
Try right click the database that you want to
restore-->Tasks-->Restore-->Database-->Restore-->Build-->Specify
Backup-->Show Location-->Options for Restore options-->Overwrite Existing
Database.  This is rough, of course, and not code or anything.  I have just
been messing with SQL for weeks, and it is starting to grow on me (like an
alien fungus  LOL).  I feel like an idiot savant.  I understand some, but I
can't open a view to extract information because I have the code wrong all
the time. This should be so simple!   I say, CREATE VIEW.........and no
matter what I type in, it says that is invalid, or improper syntax.  Its
making me crazy!

Good luck!!


Show quote
"denverdude" wrote:

> Any ideas on scripting an SQL database to overwrite another SQL database (in
> SQL2005Express??)
>
> I've got:
> RESTORE DATABASE <name>
> FROM DISK =
> ‘C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Backup\<name>.bak
>
> Is there something I'm missing?
>
> --
> denverdude in OZ

AddThis Social Bookmark Button