I have a BasicMSI project (Installshield 2009) that runs a SQL script during the installation process. During the installation I receive the following error.
Error 27506.Error executing SQL script {SCRIPTNAME}. Line 352. Incorrect syntax near ')'. (102)
The problem is that I don't have any ')' at line 352 of the script and also the script works without any problems if I run it with SQL Management Studio Express.
Can anyone tell me what is the problem and how can I fix it? Thanks.
PS. I cannot set the script error handling option to "On Error, Goto Next Statement" because therefor it will not create some of my foreign keys.
IF NOT EXISTS (SELECT * FROM sys.triggers WHERE object_id = OBJECT_ID(N'[dbo].[TRIGGER_NAME]'))
EXEC dbo.sp_executesql @statement = N'
CREATE TRIGGER [dbo].[TRIGGER_NAME]
ON [dbo].[TABLE_NAME] -- LINE: 352
INSTEAD OF INSERT
AS
BEGIN
DECLARE @Count INT;
SET @Count = (SELECT COUNT([Name])
FROM TABLE_NAME
WHERE IsDeleted = 0 AND [Name] IN (SELECT [Name] FROM INSERTED));
IF @Count > 0
BEGIN
RAISERROR (''Error Message.'', 16, 1);
Rollback;
END
ELSE
BEGIN
INSERT INTO dbo.TABLE_NAME SELECT {Columns} FROM INSERTED;
SELECT CONVERT(BigInt,SCOPE_IDENTITY()) AS [value]
END
END
'
GO