Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Making a copy of a SQL Server Table
Message
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Miscellaneous
Thread ID:
01536576
Message ID:
01536586
Views:
48
Gerard,

As a follow up to Nicholas, you could just backup your entire database at the pertinent points in time and name the backup file with that date. Then use the second database created to restore into when you want to see what you want for that point in time. This would obviously give you the desired results for all tables in the database, not just the few you wanted to copy.

Alternatively, without keeping copies of databases/tables, you could implement the following strategy. If you add two columns to your tables for created datetime (with default value equal to getdate()) and last updated datetime (add a modify trigger that updates this field to getdate() when the row has changed), you can then do a select statement that will give you a copy of the table at any point in time you want. And if you already have these columns defined and working properly now, you already have what you want.

UPDATE: Actually, this datetime function would not realy work as mentioned as if something changed multiple times you would not have access to that. You would need more update functionality to make this work.

Just two thoughts. HTH

Bob
>Hi
>In my app, at month end I need to take a copy of a few Tables, which will be refrred to occasionlly subsequently. I am wondering whats the best way of doing this in SqlServer . I do need to keep a copy of these at a pint in time, but dont particulalrly want to bloat the Database with them.
>The tables typically could be 1.6 Gigs to 2 Gigs
>
>In VFP, I used to just take a copy of the Table (as a free Table outside the database) and append the date to it (so it would be called something like MyTable_27_02_2012). This way, its kept outside the DBC, but I can refer to it easily if i need to.
>
>I have seen a BulkCopyToXml, but am concerned that , because XML causes a lot of bloat, the XML file will end up to be very large. Are there any other options worth considering ?
>Tia
>Gerard
Previous
Reply
Map
View

Click here to load this message in the networking platform