Privacy laws are changing on May 25th, and your business could be affected, regardless of your location

Learn More About GDPR Compliance

Creating a SQL Database

[fa icon="calendar"] Feb 18, 2008 4:19:00 PM / by Mertech Data Systems, Inc.

  Mertech Data Systems, Inc.

Code to create a database:

String sMsg sPath
integer iDBExist iError
handle hoWorkspace
Get phoWorkspace of (oWorkspace(oApplication(self))) To hoWorkspace Get psSQLDataPath of hoWorkspace to sPath
//Create database if not exist
SQL_START_TRANSACTION_STMT
SQL_SET_STMT    To (" if not exists (select * from master.dbo.sysdatabases where name = '" + sDataBase + "')")
SQL_APPEND_STMT To ("    CREATE DATABASE "  + sDatabase)


SQL_PREPARE_STMT
SQL_EXECUTE_STMT

SQL_SET_STMT     To ("Select Count(*) from master.dbo.sysdatabases where name = '" + sDataBase + "'")
SQL_PREPARE_STMT
SQL_EXECUTE_STMT
SQL_FETCH_NEXT_ROW Into iDBExist
SQL_COMMIT_STMT

 

Topics: Databases

Subscribe to Email Updates