0

My C# .NET (4.5.2) application accesses a local SQL Server (13.0.1601) database.

For data archival purposes my client wants to pack a snapshot of the program and the database in a folder to run the old state when needed.

How can this be achieved with no running SQL Server service but only the folder contents and an installed .NET runtime?

Options considered so far are exporting the database to .bak or .csv and putting them in the folder, but those seem to involve a lot of manual labor.

4
  • how big is this database in terms of tables / size? Commented Nov 9, 2016 at 19:52
  • 1
    One word: IT CANNOT - period. If you have a SQL Server database - there must be some form of SQL Server up and running to make use of that data. No way around that (except exporting all data into e.g. XML or another format) ..... Commented Nov 9, 2016 at 19:53
  • @Thiago: very small. ~20 tables and ~25Mb. Commented Nov 9, 2016 at 20:08
  • @marc_s: Yes that is part of the question. I am open for any exporting suggestions, if possible without any adaption of the C# source code. Commented Nov 9, 2016 at 20:12

3 Answers 3

1

As mentioned in the comments by marc, you need to have a SQL instance running to use a backup file.

Exporting it to a .bak file is not a "lot of work" - it just involves logging in to the SQL Server (from the application) and issuing the right SQL commands.

But in order to view this again you will have to re-import it back into a SQL instance - this is the reverse of the step above (although obviously you will have to rename it because your original database will still be resident in the SQL instance).

If you are looking to avoid having a SQL instance (service) installed then maybe SQL Server Express LocalDB is an option for you - it runs totally in memory.

Sign up to request clarification or add additional context in comments.

2 Comments

I had posted my own solution while @slugster was posting this one, but I like this, slugster's solution better. Should be a lot less work, and with the right scripts, going back to view a previous snapshot should be a matter of a couple of clicks.
The "lot of work" was ment for the manual code adaptions necessary to be able to use one of those formats. Thanks for the LocalDB suggestion. It's not all in one folder but it's a start.
0

You could create a script to export the tables as CSV and modify the program to use q to run its sql queries directly to those CSV files.

Comments

0

There is no embedded version of SQL Server. The closest thing is the LocalDB feature available since the 2012 version - it does require installation of some SQL Server components but does not require running a service. With it installed, you'd attach the MDF and LDF files (read-only if necessary) of the snapshot.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.