I run InstallShield 2010 to install my application which uses SQL Server. InstallShield first connects to the SQL Server as SA and then runs a few SQL scripts. The 1st script checks if a specific database exists or not. If it does not exist it returns immediately, otherwise it updates a table.
I had no problems when I ran the application install using SQL Server 2005 and 2008 R2. But I recently upgraded successfully my SQL Server 2008 R2 express to SQL Server 2012 express. InstallShield still succeeds to connect but throws an error when trying to execute the 1st script.
The SQL script is as follows:
IF NOT EXISTS (SELECT name FROM master.dbo.sysdatabases WHERE name = N'myDatabase')
return;
UPDATE [myDatabase].dbo.myTable SET current_version =2
GO
The error:
"Error executing SQL script xy, line 4. Database 'myDatabase' does not exist(2702)".
The database did not exist and so the script should have returned. Instead it seems that it tried to execute the next line and complained that the database does not exist.
This error only happens when running the SQL script from InstallShield. It does not happen when I run the script in SSMS, or when I run it from installshield on sql server 2005 and 2008 R2.
I searched all over and couldn't find anything about this problem. The syntax that this script uses has not changed in Sql Server 2012 as far as I can tell. Is there a known problem in SS 2012 that may be causing this error? Can it be related to the express edition? Has anyone encountered something similar? Any idea will be appreciated. Thanks.