Im a SQL noob but here goes - I have a trigger in SQL which is giving me an incorrect syntax error E.G:
INSERT INTO aTable
(
tTypeId,
opId,
inserted.Id
)
SELECT
3,
0,
inserted.Id
FROM inserted, tblParents
WHERE inserted.blah = 308
AND (
inserted.type = 1
AND((SELECT COUNT(*) FROM [dbo].[splitGUIDs] ([tblParents].[Parents])
WHERE [inserted].[Id] IN ([dbo].[splitGUIDs].[item])) > 0 OPTION (maxrecursion 1000);
)
OR
(
inserted.type = 2
AND((SELECT COUNT(*) FROM [dbo].[splitGUIDs] ([tblParents].[Parents])
WHERE [inserted].[Id] IN ([dbo].[splitGUIDs].[item])) > 0 OPTION (maxrecursion 1000);
)
Each of the OPTION (maxrecursion 1000) causes an invalid syntax error - but they are required for the splitGUIDs function to work correctly. How can I resolve this syntax issue?
OPTIONclause to the end of theINSERTstatement instead. – Jon Seigel Nov 8 '12 at 3:43