cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
abcd_wxyz56
Level 3

How to check the database existance in the Sql server

Hi ,

I am using basic MSI project.
With the help of SQLLogin dialogs we can create the new databse in the server.
But i am unable to inform the user whether the database is alraedy exist in the server or not.

How can i do that?
Labels (1)
0 Kudos
(5) Replies
needer
Level 4

You can add sql script follow;) :

IF NOT EXISTS (SELECT name FROM master.dbo.sysdatabases WHERE name = N'IS_SQLSERVER_DATABASE')
BEGIN
CREATE DATABASE [IS_SQLSERVER_DATABASE]
END

GO
0 Kudos
abcd_wxyz56
Level 3

Thanks For ur quick response.

But how to inform the user about the existance of the Database.
e.g:
I want to display a message to the user that "The data base is already exist.
Do you want to reuse it?"

And according to the response i want to do some work.

how ?
0 Kudos
needer
Level 4

Use InstallScript:

Function DataBaseInUse(szConnection, szServer, bTrust, szUserName, szPassword, svDB )
LIST listDBs;
NUMBER i;
begin

listDBs = SQLRTGetDatabases( szConnection, szServer, bTrust, szUserName, szPassword );

for i=0 to listDBs.Count

if(svDB = listDBs) then
MessageBox("information",WARMING);
endif

endfor;

end;
0 Kudos
hidenori
Level 17

If you are using a Basic MSI or InstallScript MSI project, existing database names will be set to the IS_SQLSERVER_LIST Windows Installer property in a comma delimited manner after you call the ISSQLQueryDatabases action.
0 Kudos
menos16
Level 4

sorry but itsn't correct :
hidenori wrote:
If you are using a Basic MSI or InstallScript MSI project, existing database names will be set to the IS_SQLSERVER_LIST Windows Installer property....


that occurs with the list of SQL SERVERS and "IS_SQLSERVER_FLATLIST" property., but not with the list of catalogs into IS_SQLSERVER_LIST

knows someone a way to do this?,
retrieve the catalog list of M$ SQL SERVER into a windows installer property
0 Kudos