totti_acmilan17
Posts: 5
Joined: Sun Jan 02, 2022 11:12 am

Create sql Database

Wed Jan 05, 2022 6:17 am

I want to create database in "D:\" and following is my script but it doesn't run!!

Code: Select all

-- Inline SQL script
USE [master]
GO
/****** Object:  Database [ExchangeDB]    Script Date: 01/04/2022 01:01:55 ب.ظ ******/
IF NOT EXISTS(SELECT * FROM sys.databases WHERE name = 'ExchangeDB')
BEGIN
CREATE DATABASE [ExchangeDB]
 CONTAINMENT = NONE
 ON  PRIMARY 
( NAME = N'ExchangeDB', FILENAME = N'D:\Exchange\DB\ExchangeDB.mdf' , SIZE = 8192KB , MAXSIZE = UNLIMITED, FILEGROWTH = 65536KB )
 LOG ON 
( NAME = N'ExchangeDB_log', FILENAME = N'D:\Exchange\DB\ExchangeDB_log.ldf' , SIZE = 8192KB , MAXSIZE = 2048GB , FILEGROWTH = 65536KB )

--ALTER DATABASE [ExchangeDB] SET COMPATIBILITY_LEVEL = 100
END
Capture3.JPG
Capture3.JPG (84.05KiB)Viewed 1979 times

Catalin
Posts: 6537
Joined: Wed Jun 13, 2018 7:49 am

Re: Create sql Database

Thu Jan 06, 2022 4:18 pm

Hello,

Before executing the script, are you connecting to the database?

If there isn't a connection between the setup and the database, please note it is normal for the script to not execute.

Have a look over the following article which explains how the connection can be achieved:

Configure MS-SQL Server Connection

From what I can see in your screenshot, this step is quite done. Besides that, I would advise checking whether the connection is successful or not through the predefined "SQLServerConnectionDlg" dialog (you can add this dialog from the "Dialogs" page).

If the connection is correctly done, then perhaps it is something with your script that doesn't work. For example, if you execute your script from SQL Server Management Studio, does it work as expected?

Best regards,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Building Installers”