.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Melody Anderson
Post New Web Links

Restore using TSQL, how to determine the files to move/overwrite

Posted By:      Posted Date: September 28, 2010    Points: 0   Category :Sql Server

There might be an easier way to perform it, if so, please advise.  I am looking for a scriptable solution (preferably TSQL).

I want to code a tsql procedure to restore a database from a backup file (.bak).  The procedure must allow to restore a backup from a database to a different database.

When performing it through the SSMS interface, I see all the files in the .bak file.  From there, I can associate the files in the backup to the appropriate files in my destination database.  when generating TSQL, this translates to MOVE statements for the files.

Can I translate the whole process in TSQL?  In order to know how to map my files, I must first gather the information on which files are present in my bak file.  Can one read the definition of the files contained in a backup file before performing the restore.  Preferably using TSQL?

View Complete Post

More Related Resource Links

overwrite the files in document library from Explorer View ?

Hi Everyone, Suppose I have a document library which can be opened using the explorer view, what happened if someone uploads to this library by drag n drop into the library with same filename? What would be the final story of the file which is overwritten through drag n drop from Explorer view ? Thanks./* Infrastructure Support Engineer */

Querystring to determine what Document Library Folder's files to list?

First of all, any webpart that alllows you to list documents in a particular folder of a Document library? Second, possible to pass what folder to list via a query string to  that webpart ? Thanks.

Move the database files to different branches before replication?


Hi all,


I want to start a replication between 3 sites using Merge replication, 1<sup>st</sup> branch is the distributer and publisher and already has a database, the others are subscribers and they are new (No data yet). But the size of the database in the main branch is about 4 GB. So if I start the replication, 4 GB will be replicated which something I don’t want. Is there a way I can put the database in the other branches manually? So nothing will need to replicate at the first time. And then replication will take place.


Waiting your valuable reply,




Not able to attach or restore northwind.mdf and northwind.ldf files



I downloaded nothwind.mdf and nothwind.ldf  files from the net.when I try to attach any of these files, i am getting the error as "Unable to open the physical file "d:\northwind.mdf".Operating system error5. 5 Access is denied.

Can you please help me to resolve this issue?

Errors when I try to move the Index files


I tried to change the location of the search index files in Central Admin.  The current setting is the default:  C:\Program Files\Microsoft Office Servers\14.0\Data\Office Server\Applications

I want to just put it on E:\Program Files\Microsoft Office Servers\14.0\Data\Office Server\Applications - so all I changed was the drive letter.

It churned for awhile then listed this error:

Errors were encountered during the configuration of the Search Service Application.

Microsoft.Office.Server.Search.Administration.SearchConfigWizard+SearchConfigWizardException: Topology provisioning failed due to an error.Topology activation was aborted because of Microsoft.Office.Server.Search.Administration.QueryComponentTransitionException: The index location E:\Program Files\Microsoft Office Servers\14.0\Data\Office Server\Applications is invalid because I/O error occurred.. ---> System.IO.IOException: I/O error occurred. at Microsoft.SharePoint.Administration.SPServer.CreateDirectory(String path, SPAclUserGroupAccessLevel userGroupAccessLevel) at Microsoft.SharePoint.Administration.SPServer.CreateSecureDirectory(String path) at Microsoft.Office.Server.Search.Administration.QueryComponent.Create

Move SharePoint Document Library Files to Local Drive

How can I move files uploaded into a MOSS 2007 Document library to a local drive? I need to automate this as a job, not a one-time process. Can I use SSIS for it? File Systems Task works fine so long as I create a map drive to the portal. I have tried both the http address and the UNC path to the portal.

Move/Copy files between SQL servers.


Hi folks,

I would like to move/copy some files between two SQL servers.  The files are consist of .css .png .jpg and .gif files.  I've tried to do this using the File System Task but I can't for the life of me work out how I point it to the servers file system.  I'm obviously not an SSIS guru, I had a play and can move files around my own PC from location to location, but can work out my server to server issue, I hope someone can help, or at least point me in the right direction.

I'm going from SQL2005 to SQL2008 if that makes any difference, but as I say its not SQL tables, data, or what not, it's simply moving files that happen to be stored on the two servers.

Thanks in advance


How to move the SQL Server SQLFT log files created by the full text catalog process.


I need to move the location of the SQLFT text log files from it's current location %ProgramFiles%\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\LOG folder to another larger drive to accomodate the log file growth.  I cannot find anything on how to make this change.  Does anyone have an answer?  I have found this is a default at install - but during install did not find how to change this. 

Thank you.



Which task would use to copy, move or delete files in SSIS

can any one help me for this question any link of examples for the same highly appreciable
Regards, Amitesh Srivastva

Restore Files.


Hi Everyone,

I have a database say DB1 having 2 data files and 1 log Files.

My objective is to restore a file of a DB1 using the backup ( Only that specified file will be backed up and restored to another database).

For that what I did ,

1. backed up the file (say mdf)  using file and filegroup option.

2. tried to restore the file in another database DB2, When I did this I got an error that File 2 was not backed up.

Please advise how to accomplish this task.


Thanks in advance



Ranjith Kumar

Ranjith Kumar Mohandas

restore lost files and addreses

During a recent electrical storm, I lost my internet, when I turned it back on my Outlook Express is totall messed up,  I lost saved folders which contained files I was keeping as well as my address book. Is there any way to recover these files and addresses?  I have Outlook Express 6.  Thanks for any help. 

Move files conditionally


The overall process I'm trying to create in SSIS/BIDS 2008 is to create (file system) folders based on values in the database and then to move a number of files, from a central location, into those sub-folders. For example, I have letters A.doc, B.doc and C.doc. In the SQL database, these files are referenced against a person number. E.g.

ID  FileName  PersonNo

1   A.doc        6231

2   B.doc        7654

3   C.doc        9876


The first part, I managed to do via an Execut SQL Task, which gets the Person Numbers and passes that into a Foreach Loop Container, which has a File System Task that creates the folder names. I combined the below approaches to make it work:



Works well, and the only change I had to make was to cast the number as char to get it into the string variable. So far so good, and it creates, in this example, the below folders:




Now I'm at the process where I need to move the files into the right folder

Web Parts move on site restore

I have an issue with web parts jumping to the bottom most web part area of my page. I backed up the site then restored it on another site. Then upon checking the pages all web parts were not in their proper places. Is there a solution to this issue or did I just do something wrong in restoring the site. Any help would be appreciated. Thank you very much.

Clean Web.Config Files (VS 2010 and .NET 4.0 Series)

.NET 4 includes a new version of the CLR, and a new .NET 4 specific machine.config file (which is installed side-by-side with the one used by .NET 2, .NET 3 and .NET 3.5).

The new .NET 4 machine.config file now automatically registers all of the ASP.NET tag sections, handlers and modules that we've added over the years, including the functionality for:

.ASP.NET Dynamic Data
.ASP.NET Routing (which can now be used for both ASP.NET WebForms and ASP.NET MVC)
.ASP.NET Chart Control (which now ships built-into ASP.NET V4)
What this means is that when you create a new "Empty ASP.NET application" project in VS 2010, you'll find that the new default application-level web.config file is now clean and simple:

Determine whether Forms Server is installed on a server

Check whether the Microsoft.Office.InfoPath.Server.dll and FormServer.aspx files are installed on the server.

SQL Server Backup and Restore (video)

Restore your full backup, then run a few queries before you keep restoring transaction logs. Brent shows how to use the Standby option for restores.

In this five minute video, Brent demonstrates how to do it by creating a database, populating data, and then showing what disaster recovery is like by doing RESTORE WITH STANDBY.

SharePoint document migration challenges when migrating files and folders

There are several challenges when migrating documents to Microsoft SharePoint. While these challenges can be overcome, they are a real pain if the migration source, content and file systems are not SharePoint friendly.
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend