Created
August 22, 2013 14:59
-
-
Save ESimmonds/6308336 to your computer and use it in GitHub Desktop.
update a table with joins
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Use Curacao | |
| GO | |
| SET XACT_ABORT ON | |
| BEGIN TRY | |
| BEGIN TRANSACTION; | |
| DECLARE @recordNumber int = 136512, @type nvarchar(10) = 'Intern' | |
| Update r | |
| Set Type = @type | |
| from RecordHolder r | |
| inner join LegacyServiceRegistration l on l.Person_id = r.PersonInfo_id | |
| where l.RecordNumber = @recordNumber | |
| --COMMIT TRANSACTION | |
| ROLLBACK TRANSACTION | |
| END TRY | |
| BEGIN CATCH | |
| N'The transaction is in an uncommittable state.' + | |
| 'Rolling back transaction.' | |
| PRINT ERROR_NUMBER() + ' ' + ERROR_MESSAGE() | |
| ROLLBACK TRANSACTION | |
| END CATCH | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment