choppaz
July 23rd, 2008, 10:29 AM
I am developing an application (C#) that needs to create a new instance of a database in the current working folder each time the program is run. It will need to be an empty database - no data, just table structures, stored procedures, etc.
So, each time it's run, the database will be created in the current working folder and populated with data from that instance of the run. C# application is going to do the work of populating the database tables. It needs to only contain data from that run, and should be unaware of the other instances of the databases in other folders.
So, the question is, how is the best way to implement this? The database currently has 90 tables, and we will need to re-create each one of them for each instance. I am considering generating a script or something from within SQL Server 2005, then running it from the C# code to create a new database when the C# application is run.
Is generating/running a SQL Server script the best approach, or would it be better to backup the empty database and restore it to the current working folder? Or to use replication (does replication make sense for empty tables, or is it only applicable to keeping data in sync across instances of the database?)
Thanks!
So, each time it's run, the database will be created in the current working folder and populated with data from that instance of the run. C# application is going to do the work of populating the database tables. It needs to only contain data from that run, and should be unaware of the other instances of the databases in other folders.
So, the question is, how is the best way to implement this? The database currently has 90 tables, and we will need to re-create each one of them for each instance. I am considering generating a script or something from within SQL Server 2005, then running it from the C# code to create a new database when the C# application is run.
Is generating/running a SQL Server script the best approach, or would it be better to backup the empty database and restore it to the current working folder? Or to use replication (does replication make sense for empty tables, or is it only applicable to keeping data in sync across instances of the database?)
Thanks!