>Hi,
>
>I have the following constraint set on the foreign key field of the child table:
>
>
>ALTER TABLE [dbo].[child_tbl] WITH CHECK ADD CONSTRAINT [FK_child_tbl_employee] FOREIGN KEY([employee])
>REFERENCES [dbo].[parent_tbl] ([employee])
>
>
>Why do you think the following code in the SSMS gets error of constraint conflict?
>
>
>use [MyDatabase]
>go
>begin transaction
>update parent_tbl set employee = 'TEST34' where employee = 'TEST1'
>go
>update child_tbl set employee = 'TEST34' where employee = 'TEST1'
>go
>commit
>
>
>TIA
GO statement in SSMS ends the batch (it's a bacth separator). You started transaction but you never ended it in the first batch, so I assume it rollbacked by default. You need to commit it before GO, then the second statement will work. But also, for a single statement you don't need a transaction at all.
If it's not broken, fix it until it is.
My Blog