question

Equus avatar image
Equus asked

Syntax error 46010 indicated by migration tool

Used the migration tool to upgrade SQL Server 2012 SP4 to 2019 and received notification that sever triggers had syntax errors, error code 46010. Since I relatively new in this arena and didn't author the code, I need some help. The code looks like this:

GO

/****** Object: Trigger [dbo].[T_TblEtl_ITrig] Script Date: 16-Sep-2021 13:04:34 ******/

SET ANSI_NULLS ON

GO

SET QUOTED_IDENTIFIER ON

GO

ALTER TRIGGER [dbo].[T_TblEtl_ITrig] ON [dbo].[TblEtl] FOR INSERT AS

SET NOCOUNT ON

/* * PREVENT INSERTS IF NO MATCHING KEY IN 'TBL_XXXX' */

IF (SELECT COUNT(*) FROM inserted) !=

(SELECT COUNT(*) FROM TBL_XXX, inserted WHERE (TBL_XXX.sm_group_id = inserted.EtGrpId))

BEGIN

RAISERROR ( 50006,16,1)

ROLLBACK TRANSACTION

END

sql server
10 |1200 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Equus avatar image
Equus answered

Thank you, I will give that a try.


10 |1200 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

anthony.green avatar image
anthony.green answered

The old style join syntax is no longer valid so your

TBL_XXX, inserted

Needs to be rewritten as an inner join instead.

From TBL_XXX
INNER JOIN
Inserted


2 comments
10 |1200 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

I am struggling to make this work. Very green in this arena. Any assistance is appreciated.
0 Likes 0 ·
/****** Object: Trigger [dbo].[T_TblEtl_ITrig] Script Date: 16-Sep-2021 13:04:34 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER TRIGGER [dbo].[T_TblEtl_ITrig] ON [dbo].[TblEtl] FOR INSERT AS
SET NOCOUNT ON
/* * PREVENT INSERTS IF NO MATCHING KEY IN 'TBL_XXXX' */

IF (SELECT COUNT(*) FROM inserted) !=
(SELECT COUNT(*) FROM TBL_XXX INNER JOIN inserted ON (TBL_XXX.sm_group_id = inserted.EtGrpId))
BEGIN
RAISERROR ( 50006,16,1)
ROLLBACK TRANSACTION
END
0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.