Red Gate forums :: View topic - Potential data loss for table rebuild with transactions off
Return to www.red-gate.com RSS Feed Available

Search  | Usergroups |  Profile |  Messages |  Log in  Register 
Go to product documentation
SQL Compare 10
SQL Compare 10 forum

Potential data loss for table rebuild with transactions off

Search in SQL Compare 10 forum
Post new topic   Reply to topic
Jump to:  
Author Message
matt_hosking



Joined: 07 Sep 2011
Posts: 14
Location: Australia

PostPosted: Thu Oct 04, 2012 8:02 am    Post subject: Potential data loss for table rebuild with transactions off Reply with quote

SQL Compare decided to rebuild a table in our deployment script as it couldn't perform alters and since we don't have transactions enabled for the deployment script, we ended up with something like this:

SET IDENTITY_INSERT [dbo].[tmp_rg_xx_tblPerson] ON
GO
INSERT INTO [dbo].[tmp_rg_xx_tblPerson]([fldPersonID], ...) SELECT [fldPersonID], ... FROM [dbo].[tblPerson]
GO
SET IDENTITY_INSERT [dbo].[tmp_rg_xx_tblPerson] OFF
GO
DECLARE @idVal BIGINT
SELECT @idVal = IDENT_CURRENT(N'[dbo].[tblPerson]')
IF @idVal IS NOT NULL
DBCC CHECKIDENT(N'[dbo].[tmp_rg_xx_tblPerson]', RESEED, @idVal)
GO
DROP TABLE [dbo].[tblPerson]
GO

The problem here, which is fairly evident, is that this script will not care if the migration of records is successful when it drops the original table. I know that turning on transactions would help here, and databases should always be backed up before running scripts, but should SQL compare ever generate a script that will potentially destroy your data if an error occurs?

My proposal is that even when transactions are off, the insert to the drop should always be wrapped in a transaction. Is this a recorded issue somewhere? Otherwise, should I log it?
Back to top
View user's profile Send private message
Manfred.Castro



Joined: 23 Apr 2012
Posts: 205

PostPosted: Mon Oct 08, 2012 6:26 pm    Post subject: Reply with quote

You can request features for this product in our uservoice forums.
http://redgate.uservoice.com/forums/141379-sql-compare-feature-suggestions
These forums are monitored by our developers and allow our users to request features and vote on them.
If a request recieves significant support the feature may be included in a future release.
_________________
Manfred Castro
Product Support
Red Gate Software
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic All times are GMT + 1 Hour
Page 1 of 1

 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group