Advertisement
Guest User

Untitled

a guest
Sep 18th, 2017
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
T-SQL 1.38 KB | None | 0 0
  1. /*
  2. *
  3. * BEGIN VERSION 0_3_20
  4. *
  5. */
  6. IF NOT EXISTS (
  7.     SELECT *
  8.     FROM LBProConversion
  9.     WHERE ConversionType = 'VER_0_3_20' AND IsDone = 1 AND [Type] = @TYPE)
  10. BEGIN
  11.  
  12.     BEGIN TRAN VER_0_3_20;
  13.         PRINT('Begin of conversion for version : 0_3_20');
  14.  
  15.         IF NOT EXISTS (SELECT 1 FROM sysobjects o INNER JOIN syscolumns AS c ON c.Id = o.Id AND (c.Name = 'BarCodeFormat')
  16.             WHERE o.XType = 'U' AND o.name = 'IRClient')
  17.         BEGIN
  18.             PRINT 'Rename IRClient.BarCodeFormat to IRClient.BarCodeFormatEquipment'
  19.  
  20.             EXEC sp_rename 'Intellirent.dbo.IRClient.BarCodeFormat', 'BarCodeFormatEquipment', 'COLUMN';
  21.  
  22.             PRINT 'Add columns BarCodeFormat in table IRClient'
  23.             ALTER TABLE IRClient ADD BarCodeFormatDocument NVARCHAR(50) NULL
  24.             ALTER TABLE IRClient ADD BarCodeFormat NVARCHAR(50) NULL
  25.            
  26.             IF @@ERROR <> 0 GOTO ERROR_0_3_20;
  27.         END
  28.        
  29.         -----------------------------------------------------------------------
  30.         -- INSERT ACTUAL VERSION 0_3_20
  31.         INSERT INTO LBProConversion (ConversionType, IsDone, ConversionDateUTC, [Type])
  32.         VALUES ('VER_0_3_20', 1, GETUTCDATE(), @TYPE)
  33.  
  34.         IF @@ERROR <> 0 GOTO ERROR_0_3_20;
  35.  
  36.         GOTO END_0_3_20;
  37.  
  38.     ERROR_0_3_20:
  39.         PRINT('Error while converting to version : 0_3_20');
  40.         ROLLBACK TRAN VER_0_3_20;
  41.         GOTO ENDFILE;
  42.  
  43.     END_0_3_20:
  44.         PRINT('Successful converting to version : 0_3_20');
  45.         COMMIT TRAN VER_0_3_20;
  46. END
  47. /*
  48. *
  49. * END VERSION 0_3_20
  50. *
  51. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement