SET NOCOUNT ON BEGIN TRANSACTION DECLARE @tab VARCHAR(1) DECLARE @nl VARCHAR(2) SET @tab=CHAR(09) SET @nl=CHAR(0x0D)+CHAR(0x0A) PRINT 'Script running started!' PRINT @nl -- updating TAK_FIELDS IF EXISTS (SELECT * FROM sysobjects WHERE UPPER(name)='TAK_FIELDS' AND xtype='U') BEGIN UPDATE TAK_Fields SET locked=1, required=0, editfield=0 WHERE (FIELDNAME = 'clientStateValid') OR (FIELDNAME = 'structureModified') IF @@ERROR<>0 BEGIN PRINT @tab+'ERROR: Error happened during updating records of TAK_Fields table!' GOTO ONERROR END END ELSE BEGIN PRINT @tab+'ERROR: Error happened during updating records of TAK_Fields table, table is missing!' GOTO ONERROR END PRINT @tab+'TAK_Fields records were succesfully updated!' COMMIT GOTO DOEXIT ONERROR: PRINT @tab+'ERROR: Some error happened during running the script, modifications were rolled back!' RAISERROR('ERROR: Some error happened during running the script, modifications were rolled back!', 16, 10) ROLLBACK GOTO DOEXIT DOEXIT: PRINT @nl+'Script finished running!'