Snitz Forums 2000
Snitz Forums 2000
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Help Groups for Snitz Forums 2000 Users
 Help: Database: MS SQL Server
 Copy data between MSSQL databases on same server
 New Topic  Topic Locked
 Printer Friendly
Author Previous Topic Topic Next Topic  

Podge
Support Moderator

Ireland
3776 Posts

Posted - 17 August 2006 :  09:17:38  Show Profile  Send Podge an ICQ Message  Send Podge a Yahoo! Message
One client of mine has accidently managed to delete about 11,000 topics by deleting the forum they were contained in. The client has setup new forums and categories on the board and a few new topics have also been created.

I have a backup from two days before the deletion which I have managed to restore but I cannot replace the database with the backup as there are a number of other forums run off the same database. I had planned to copy over the data from the following tables in the backup into the tables in the live forum but dts fails everytime (I presume because of the size of the database or number of tables)

FORUM_TOPICS
FORUM_REPLY
FORUM_FORUM
FORUM_CATEGORY

Am I right in thinking that any new topics, forums & categories will have different id's and that the backup data will not interfere (or cause problems) with the new forum?

I cannot use dts to transfer the tables and will have to use some form of SELECT INTO query. Does anyone have any examples of SQL for copying data between databases?

Anything else I've forgotton?

Podge.

The Hunger Site - Click to donate free food | My Blog | Snitz 3.4.05 AutoInstall (Beta!)

My Mods: CAPTCHA Mod | GateKeeper Mod
Tutorial: Enable subscriptions on your board

Warning: The post above or below may contain nuts.

ruirib
Snitz Forums Admin

Portugal
26364 Posts

Posted - 17 August 2006 :  09:36:37  Show Profile  Send ruirib a Yahoo! Message
1. Why does DTS fail? What's the error message?

2. If it's the same DB, yeah, I'd say there should be no repeated topic, reply, cat and forum ids;

3. DTS would be the best option and the only one I had to use in the past. I guess if it really won't be usable, you will need to write a simple script that set's identity off, then uses a INSERT INTO query, indeed and then sets identity on again. I suppose that if you use a full database.user.table syntax in the query, all should go ok, but it's rather easy to test with a single record...


Snitz 3.4 Readme | Like the support? Support Snitz too
Go to Top of Page

Podge
Support Moderator

Ireland
3776 Posts

Posted - 17 August 2006 :  10:05:44  Show Profile  Send Podge an ICQ Message  Send Podge a Yahoo! Message
I tried using the dts wizard in EM and EM just quit after a few minutes. Nothing in the event viewer. I assume its because of the number of tables in the db.

Had forgotton about the identity insert thing. Time to revisit this - http://forum.snitz.com/forum/topic.asp?TOPIC_ID=59319

Podge.

The Hunger Site - Click to donate free food | My Blog | Snitz 3.4.05 AutoInstall (Beta!)

My Mods: CAPTCHA Mod | GateKeeper Mod
Tutorial: Enable subscriptions on your board

Warning: The post above or below may contain nuts.
Go to Top of Page

ruirib
Snitz Forums Admin

Portugal
26364 Posts

Posted - 17 August 2006 :  10:35:19  Show Profile  Send ruirib a Yahoo! Message
Well I never had an issue with the number of tables... but then I guess your number may be high :)... shouldn't be an issue anyway, or so I think.


Snitz 3.4 Readme | Like the support? Support Snitz too
Go to Top of Page

Podge
Support Moderator

Ireland
3776 Posts

Posted - 17 August 2006 :  18:35:17  Show Profile  Send Podge an ICQ Message  Send Podge a Yahoo! Message
This worked for me;

use master
go

-- FORUM_FORUM
SET IDENTITY_INSERT [destination_db].[dbo].[FORUM_FORUM] ON
INSERT INTO [destination_db].[dbo].[FORUM_FORUM]([CAT_ID], [FORUM_ID], [F_STATUS], [F_MAIL], [F_SUBJECT], [F_URL], [F_DESCRIPTION], [F_TOPICS], [F_COUNT], [F_LAST_POST], [F_PASSWORD_NEW], [F_PRIVATEFORUMS], [F_TYPE], [F_IP], [F_LAST_POST_AUTHOR], [F_LAST_POST_TOPIC_ID], [F_LAST_POST_REPLY_ID], [F_A_TOPICS], [F_A_COUNT], [F_DEFAULTDAYS], [F_COUNT_M_POSTS], [F_MODERATION], [F_SUBSCRIPTION], [F_ORDER], [F_L_ARCHIVE], [F_ARCHIVE_SCHED], [F_L_DELETE], [F_DELETE_SCHED], [F_POLLS]) 
SELECT [CAT_ID], [FORUM_ID], [F_STATUS], [F_MAIL], [F_SUBJECT], [F_URL], [F_DESCRIPTION], [F_TOPICS], [F_COUNT], [F_LAST_POST], [F_PASSWORD_NEW], [F_PRIVATEFORUMS], [F_TYPE], [F_IP], [F_LAST_POST_AUTHOR], [F_LAST_POST_TOPIC_ID], [F_LAST_POST_REPLY_ID], [F_A_TOPICS], [F_A_COUNT], [F_DEFAULTDAYS], [F_COUNT_M_POSTS], [F_MODERATION], [F_SUBSCRIPTION], [F_ORDER], [F_L_ARCHIVE], [F_ARCHIVE_SCHED], [F_L_DELETE], [F_DELETE_SCHED], [F_POLLS] FROM [backup_db].[dbo].[FORUM_FORUM]  
SET IDENTITY_INSERT [destination_db].[dbo].[FORUM_FORUM] OFF
go

-- FORUM_CATEGORY
SET IDENTITY_INSERT [destination_db].[dbo].[FORUM_CATEGORY] ON
INSERT INTO [destination_db].[dbo].[FORUM_CATEGORY]([CAT_ID], [CAT_STATUS], [CAT_NAME], [CAT_MODERATION], [CAT_SUBSCRIPTION], [CAT_ORDER]) 
SELECT [CAT_ID], [CAT_STATUS], [CAT_NAME], [CAT_MODERATION], [CAT_SUBSCRIPTION], [CAT_ORDER] FROM [backup_db].[dbo].[FORUM_CATEGORY]  
SET IDENTITY_INSERT [destination_db].[dbo].[FORUM_CATEGORY] OFF
go

-- FORUM_TOPICS
SET IDENTITY_INSERT [destination_db].[dbo].[FORUM_TOPICS] ON
INSERT INTO [destination_db].[dbo].[FORUM_TOPICS]([CAT_ID], [FORUM_ID], [TOPIC_ID], [T_STATUS], [T_MAIL], [T_SUBJECT], [T_MESSAGE], [T_AUTHOR], [T_REPLIES], [T_UREPLIES], [T_VIEW_COUNT], [T_LAST_POST], [T_DATE], [T_LAST_POSTER], [T_IP], [T_LAST_POST_AUTHOR], [T_LAST_POST_REPLY_ID], [T_ARCHIVE_FLAG], [T_LAST_EDIT], [T_LAST_EDITBY], [T_STICKY], [T_SIG], [T_MSGICON], [T_ISPOLL], [T_POLLSTATUS]) 
SELECT [CAT_ID], [FORUM_ID], [TOPIC_ID], [T_STATUS], [T_MAIL], [T_SUBJECT], [T_MESSAGE], [T_AUTHOR], [T_REPLIES], [T_UREPLIES], [T_VIEW_COUNT], [T_LAST_POST], [T_DATE], [T_LAST_POSTER], [T_IP], [T_LAST_POST_AUTHOR], [T_LAST_POST_REPLY_ID], [T_ARCHIVE_FLAG], [T_LAST_EDIT], [T_LAST_EDITBY], [T_STICKY], [T_SIG], [T_MSGICON], [T_ISPOLL], [T_POLLSTATUS] FROM [backup_db].[dbo].[FORUM_TOPICS]  
SET IDENTITY_INSERT [destination_db].[dbo].[FORUM_TOPICS] OFF
go


-- FORUM_REPLY
SET IDENTITY_INSERT [destination_db].[dbo].[FORUM_REPLY] ON
INSERT INTO [destination_db].[dbo].[FORUM_REPLY]([CAT_ID], [FORUM_ID], [TOPIC_ID], [REPLY_ID], [R_MAIL], [R_AUTHOR], [R_MESSAGE], [R_DATE], [R_IP], [R_STATUS], [R_LAST_EDIT], [R_LAST_EDITBY], [R_SIG], [R_MSGICON]) 
SELECT [CAT_ID], [FORUM_ID], [TOPIC_ID], [REPLY_ID], [R_MAIL], [R_AUTHOR], [R_MESSAGE], [R_DATE], [R_IP], [R_STATUS], [R_LAST_EDIT], [R_LAST_EDITBY], [R_SIG], [R_MSGICON] FROM [backup_db].[dbo].[FORUM_REPLY]  
SET IDENTITY_INSERT [destination_db].[dbo].[FORUM_REPLY] OFF
go


I know I will need it again.

Podge.

The Hunger Site - Click to donate free food | My Blog | Snitz 3.4.05 AutoInstall (Beta!)

My Mods: CAPTCHA Mod | GateKeeper Mod
Tutorial: Enable subscriptions on your board

Warning: The post above or below may contain nuts.
Go to Top of Page

ruirib
Snitz Forums Admin

Portugal
26364 Posts

Posted - 17 August 2006 :  19:24:15  Show Profile  Send ruirib a Yahoo! Message
Glad it worked...


Snitz 3.4 Readme | Like the support? Support Snitz too
Go to Top of Page

Podge
Support Moderator

Ireland
3776 Posts

Posted - 04 December 2007 :  19:39:31  Show Profile  Send Podge an ICQ Message  Send Podge a Yahoo! Message
Told ya I would need it again !

Podge.

The Hunger Site - Click to donate free food | My Blog | Snitz 3.4.05 AutoInstall (Beta!)

My Mods: CAPTCHA Mod | GateKeeper Mod
Tutorial: Enable subscriptions on your board

Warning: The post above or below may contain nuts.
Go to Top of Page

AnonJr
Moderator

United States
5768 Posts

Posted - 04 December 2007 :  19:51:20  Show Profile  Visit AnonJr's Homepage
Same client?

I have to add that I rib one of the guys at the Jesus Joshua forum every chance I get because he did something similar. I get a phone call that starts with "Mark, you'll either be very entertained or very upset..."
Go to Top of Page

Podge
Support Moderator

Ireland
3776 Posts

Posted - 04 December 2007 :  19:55:19  Show Profile  Send Podge an ICQ Message  Send Podge a Yahoo! Message
Nope.

Podge.

The Hunger Site - Click to donate free food | My Blog | Snitz 3.4.05 AutoInstall (Beta!)

My Mods: CAPTCHA Mod | GateKeeper Mod
Tutorial: Enable subscriptions on your board

Warning: The post above or below may contain nuts.
Go to Top of Page

HuwR
Forum Admin

United Kingdom
20600 Posts

Posted - 05 December 2007 :  03:22:36  Show Profile  Visit HuwR's Homepage
You may want to check the archive tables as well since if you delete a forum it will delete the archived topics/replies as well (and subscriptions)
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Topic Locked
 Printer Friendly
Jump To:
Snitz Forums 2000 © 2000-2021 Snitz™ Communications Go To Top Of Page
This page was generated in 0.23 seconds. Powered By: Snitz Forums 2000 Version 3.4.07