Click here to Skip to main content
15,741,692 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I have a bak file database from sql server. I want to restore it from vb net project. I want to restore it with a different name than the original database I have backup it with different name of the original can I restore it with the different name?

What I have tried:

I found this code but didnt try it
string connStr = "Data Source=(local);Initial Catalog=db;
       Integrated Security=SSPI;Connection Timeout=30";
it is nòt the full code bùt it is restòring the bak file all I want is if I can restore it with different name.
Updated 17-Jan-22 4:54am
CHill60 17-Jan-22 7:07am    

1 solution

See here: Restore a Database to a New Location (SQL Server) - SQL Server | Microsoft Docs[^] - it's under the "T-SQL" section.

But I would strongly suggest that it's probably not the right approach: Backups are meant to be just that, and restoring it to the same server with a new name is just duplicating data and potentially introducing a lot of confusion. If you are intending to clone a DB so you can use it on a development machine, that is even more risky, as it exposes you to GDPR (and local Data Protection legislation) restrictions breaches of which causes fines which can be truly astronomical.
I'd think really carefully before I went ahead if I was you.
Share this answer
Maciej Los 17-Jan-22 16:30pm    

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900