Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
Kowalski
Starting Member
3 Posts |
Posted - 2008-04-01 : 04:44:31
|
| Hi, trying to affect schema changes on an SQL DB using however Im encountering a number of errors when trying to do this. Changes are are affected by running a consecutive number of scripts against the DB, see example of script below:-- PREVIOUSDBVERSION=2.8.2.5-- The above line must be present in all Upgrade SQL files to catch any gaps in the upgrade chain.----ALL--SET NUMERIC_ROUNDABORT OFFGOSET ANSI_PADDING, ANSI_WARNINGS, CONCAT_NULL_YIELDS_NULL, ARITHABORT, QUOTED_IDENTIFIER, ANSI_NULLS ONGOIF EXISTS (SELECT * FROM tempdb..sysobjects WHERE id=OBJECT_ID('tempdb..#tmpErrors')) DROP TABLE #tmpErrorsGOCREATE TABLE #tmpErrors (Error int)GOSET XACT_ABORT ONGOSET TRANSACTION ISOLATION LEVEL SERIALIZABLEGOBEGIN TRANSACTIONGOPRINT N'Dropping Stats from A DB'GO DECLARE @tblname sysname, @statname sysname, @sql nvarchar(2000) DECLARE c CURSOR FOR SELECT object_name(id), name FROM sysindexes WHERE INDEXPROPERTY(id, name, 'IsStatistics') = 1 OPEN c FETCH NEXT FROM c INTO @tblname, @statname WHILE @@FETCH_STATUS = 0 BEGIN SET @sql = 'DROP STATISTICS [' + @tblname + '].[' + @statname + ']' PRINT @sql EXEC (@sql) FETCH NEXT FROM c INTO @tblname, @statname END CLOSE c DEALLOCATE cGOIF @@ERROR<>0 AND @@TRANCOUNT>0 ROLLBACK TRANSACTIONGOIF @@TRANCOUNT=0 BEGIN INSERT INTO #tmpErrors (Error) SELECT 1 BEGIN TRANSACTION ENDGOThe database I am upgrading has a growth limit of 2GB, when running the scripts against the DB two things are happening.1) DB size begins to increase rapidly and eventually breaches 2GB mark2) LDF file swells to upto 3GBMy first thought is that the schema changes are gathering in the log file and not being commited to the DB, or that there is some kind of open transaction that the script is constantly trying to execute over and over.Would like to point out im a novice SQL user, if the information above is sketchy please dont hesitate to say and I will endeavour to provide you with more accurate information.Cheers |
|
|
nr
SQLTeam MVY
12543 Posts |
Posted - 2008-04-01 : 05:51:43
|
| Well you have a begin transaction statement so all this will be run in a transaction.All you are doing is dropping statistics (for some reason) so why do you want a transaction.==========================================Cursors are useful if you don't know sql.DTS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
|
|
|
|
|
|