Database Server Setup for Microsoft SQL Server 2022 on Windows¶
- Database Server Setup for Microsoft SQL Server 2022 on Windows
- Prerequisite
- Download of Binaries and Installation Process
- Configuring SQL Instance
- Configure Windows Firewall (Windows Server 2025)
- Test TCP Access with CLI
- Creating Users
- Install MSSQL Client on Ubuntu
- Project Configurations for Conversion and Import of the Database(s)
- Configurations for Running your Project
- Setting up the MSSQL database manually
This wiki discusses the setup and configuration of SQL Server and the setup of the FWD server and the environment to be able to run backed by the SQL Server instance. This is focused on general procedure and, if needed, the hotel_gui is given as example. Customer specific wikis may refer this document to avoid duplicating information.
Prerequisite¶
The installation of SQL Server 2022 requires a modern OS. We tested Windows 11 Pro and Windows Server 2025 Standard. Also make sure you have at least 2GB free space for installer and 20 GB for each created instance. Additionally, make sure you have enough space for database (data, indexes, logs, etc). Note that, during the SQL instance setup you can choose a dedicated disk for data. See second bullet of step 11 in Download of Binaries and Installation Process below.
Download of Binaries and Installation Process¶
The SQL Server 2022 Developer can be downloaded from https://www.microsoft.com/en-us/sql-server/sql-server-downloads. The same page will offer links for download for other versions of SQL Server, but we not interested in them at this time.
- Click on
SQL Server 2022 Developerbox and the browser will download a small installer namedSQL2022-SSEI-Dev.exe; - Execute it to start the download and setup wizard;
- Choose
Custombutton. It will ask for a location (Media Location) where the downloaded package will be saved and then unpacked. Note that the files from this folder should be kept in case in case you want to add new features of modify an existing SQL instance. To make changes to SQL server installation you can use thesetup.exeapplication which will be placed here by the installer; - After choosing the right location, click
Install. It will download and unpack the setup files. When finished, it will automatically launch the setup application which will open theSQL Server Installation Center; - From the left menu, click
Installation, thenNew SQL Server standalone installation or add features to an existing installation; - A new window will open prompting for edition. The
Developershould be preselected. ClickNext >; - Read and accept the license terms by checking the respective checkbox. Click
Next >; - The setup will scan the system and show a summary. Ideally, all should be green. In my case there was a yellow warning for
Windows Firewall. We will handle this later. ClickNext >; - Setup offers to install/configure
Azure Extension. Uncheck the checkbox at the top of the window and clickNext >; - A list of features is shown. I enabled only the
Full-Text and Semantic Extraction Search, just in case we will use it for a specific implementation ofcontainsfunction/4GL Word Indexes. ClickNext >; - Instance Configuration. We go with a named instance called
fwdcluster. ClickNext >; - Server configuration. The default
Collationwill generally suit your project due to compatibility with 1252 CP text encoding. ClickNext >; - Database Engine Configuration
- In
Server Configurationtab:- Select
Mixed Mode (SQL Server authentication and Windows authentication) radio button. - Enter a STRONG password for
sa; - Click
Add Current Userto set it as system administrator;
- Select
- Optionally, in
Data Directoriesthe location where the database is saved can be chosen. Note: you may want pick a location on your fastest device. Make sure it have at least 100GB free space;
- In
- You guessed it, click
Next >; - A summary will be presented on
Ready to installpage. ClickInstallto start the installation process. - Hopefully, all features will be successfully installed (marked green check). Click
Close;
- Choose
SQL Server Management Studio should be installed since it is a better solution for executing SQL statements in isolation and testing than the CLI (sqlcmd).
- go to
https://learn.microsoft.com/en-us/ssms/install/installin your browser. The latest version is SSMS21, downloadable from https://aka.ms/ssms/21/release/vs_SSMS.exe; - after the download finished, launch
vs_SSMS.exe:- Click
Continue; - Click
Installto start the process of downloading and installing of components; - Click
OKwhen process ends and then you can close theVisual Studio Installerapplication.
- Click
- From
Startmenu, start the newSQL Server Management Studio 21;- Click
Skip and add accounts laterlink - From
Filemenu, clickConnect Object Explorer - Click
Browse(at the top) thenLocal. The newly created server instance should appear. Select it; - Click
Trust Server Certificatecheckbox. TODO: discuss security issues; - Click
Connect. TheObject Explorerin the left side will show a tree structure of existing databases and their structure.
- Click
Configuring SQL Instance¶
- From
Startmenu, openSql Server Configuration Manager; - Select
Protocols for FWDCLUSTERunderSQL Server Network Configuration;TCP/IPis most likely disabled. Double click it to open its properties;- In
Protocoltab, clickEnabledand chooseYes; - In
IP Addresses, scroll to bottom and inIPAll/TCP Portenter1433, the default static port for SQL Server; - Click
OKto close the properties dialog. A warning will be shown requesting to restart the instance;
- Go to
SQL Server Servicesand selectSQL Server (FWDCLUSTER). It should be inRunningstate;- Click
Restart Servicebutton from toolbar (has a blue rounded arrow icon).
- Click
Configure Windows Firewall (Windows Server 2025)¶
- From
Startmenu, openWindows Defender Firewall with Advanced Firewall; - From the left panel, right-click
Inbound Rulesto open contextual menu; - Select
New Rule...to openNew Inbound Rule Wizard; - Select
PortRule Type thenNext >; - Select
TCPand enter1433(default, or other if you went for a different value inIP Addressesabove) inSpecific local portseditbox. ClickNext >; - Keep
Allow the connectionselected and clickNext >; - Make sure
Publicnetwork is checked and clickNext >; - Type a name for the new rule (Ex:
Allow inbound on default SQL Server port) and clickFinish.
Test TCP Access with CLI¶
The next paragraphs use 192.168.0.130 as the IP of the machine where SQL Server runs. To obtain the IP of the machine use ipcpnfig command from Windows prompt.
- open a console (CMD or PowerShell)
- execute
sqlcmd -S 192.168.0.130,1433 -C
If 1> prompt is displayed, then everything is well configured and queries can be tested. You can type
1> select 1+1, db_name()
2> goThe expected response is---- --------- 2 masterEach statement is executed only on
go.
If an error is printed, then go back and check:
- if the
TCP/IPprotocol isEnabledforFWDCLUSTERinstance; - if the port is correctly set to
1433(or other you have chosen); - if you restarted the instance after setting the above settings;
- the IP is correct;
- the port is correctly configured in firewall.
Creating Users¶
Using the SQL Server Management Studio or the sqlcmd CLI execute the following statements:
CREATE LOGIN fwd_user WITH PASSWORD = 'user';
CREATE USER fwd_user FOR LOGIN fwd_user;
ALTER ROLE db_owner ADD MEMBER fwd_user;
CREATE LOGIN fwd_admin WITH PASSWORD = 'admin';
ALTER SERVER ROLE [dbcreator] ADD MEMBER [fwd_admin]
CREATE USER fwd_admin FOR LOGIN fwd_admin;
ALTER ROLE db_owner ADD MEMBER fwd_admin;
Install MSSQL Client on Ubuntu¶
curl -fsSL https://packages.microsoft.com/keys/microsoft.asc | sudo gpg --dearmor -o /usr/share/keyrings/microsoft-prod.gpg sudo chmod 644 /usr/share/keyrings/microsoft-prod.gpg curl https://packages.microsoft.com/config/ubuntu/24.04/prod.list | sudo tee /etc/apt/sources.list.d/mssql-release.list sudo apt-get update sudo apt-get install mssql-tools18 unixodbc-dev echo 'export PATH="$PATH:/opt/mssql-tools18/bin"' >> ~/.bash_profile source ~/.bash_profile ln -s /opt/mssql-tools18/bin /usr/bin/
Project Configurations for Conversion and Import of the Database(s)¶
I am putting these here only as a reference. Please update the values according to your machine.
Static conversion:./cfg/p2j.cfg.xml. make suresqlserver2012is appended to the list ofddl-dialectsfor the namespaces:
There are no specific settings for this dialect.<namespace name="hotel" importFile="data/hotel.df" default="true" > <parameter name="ddl-dialects" value="h2,postgresql,mariadb,sqlserver2012" /> [...] </namespace>
./build.properties. The IP and port number are from my configuration. Please see yours fromEnable TCP/IP connectionsabove.# db dialects
db.h2=false
db.postgresql=false
db.mariadb=false
db.sqlserver=true
#db connection info
db.host=192.168.0.130
db.port=1433
db.instance=\\FWDCLUSTER
Important note:
When accessing the SQL Server instance from guest Ubuntu OS in a WSL2, the localhost / 192.168.0.1 and localname cannot be used. The guest OS is a different machine with different network adapters and different sets of ports. Using these will cause FWD (and sqlcmd and any other application running in Ubuntu) to try to connect to local/guest port, not the port on the host machine where SQL Server instance runs. So, it will fail.
To properly configure the import/runtime use the external IP of the host OS, or its external name if it is correctly resolved by the DNS of the guest OS. Basic ping and telnet commands can be used to troubleshoot and choose the right host.
Configurations for Running your Project¶
deploy/server/directory.xml(runtime). Make sure theurluses the same IP / port as above.<node class="container" name="server"> <node class="container" name="standard"> <node class="container" name="database"> <node class="container" name="hotel"> <node class="container" name="orm"> <node class="string" name="dialect"> <node-attribute name="value" value="com.goldencode.p2j.persist.dialect.P2JSQLServer2012Dialect"/> </node> <node class="container" name="connection"> <node class="string" name="driver_class"> <node-attribute name="value" value="com.microsoft.sqlserver.jdbc.SQLServerDriver"/> </node> <node class="string" name="url"> <node-attribute name="value" value="jdbc:sqlserver://192.168.0.130\\FWDCLUSTER:1433;databaseName=hotel;encrypt=true;trustServerCertificate=true;"/> </node>
Setting up the MSSQL database manually¶
The above paragraphs describe the configurations needed to be performed when using a provided ant script. But what happens behind the scene? Or if you want to manually create and configure the MSSQL database to be used with FWD server? Use the following statements, fromSQL Management Studio or sqlcmd. In the examples, hotel database is used. Please replace with your desired database name.
- create the database:
create database [hotel] - set the collation:
The list of all available collations can be seen at the step 10 of instance's Installation Process above.ALTER DATABASE [hotel] COLLATE Latin1_General_100_CS_AI_SC_UTF8 - apply schema. It can be found in
ddl/directory in the conversion project. Execute theddl/schema_table_hotel_sqlserver2012.sqlto get the tables and necessary database options set. Execute theddl/schema_index_hotel_sqlserver2012.sqlonly if an import process will not be performed. - grant the necessary permissions to
fwd_user, assuming the login entity was already created at instance level, as described above:
While the membership toCREATE USER [fwd_user] FOR LOGIN [fwd_user]; ALTER USER [fwd_user] WITH DEFAULT_SCHEMA=[dbo], LOGIN=[fwd_user]; ALTER ROLE [db_datawriter] ADD MEMBER [fwd_user]; ALTER ROLE [db_datareader] ADD MEMBER [fwd_user]; ALTER ROLE [db_ddladmin] ADD MEMBER [fwd_user];db_datawriteranddb_datareaderare obvious, the requirement fordb_ddladminis necessary because the implementation ofset-value4GL statement is seen as a DDL statement by SQL Server. - additionally, the following will be necessary if the schema was not applied:
These are part of the header ofALTER DATABASE [hotel] SET ALLOW_SNAPSHOT_ISOLATION OFF; ALTER DATABASE [hotel] SET READ_COMMITTED_SNAPSHOT ON;ddl/schema_table_hotel_sqlserver2012.sqland will be set with schema installation.
These are mandatory for allowing concurrent access (eventually in read-only / no-lock mode) to same table from different connections (user contexts in 4GL/FWD).
© 2004-2025 Golden Code Development Corporation. ALL RIGHTS RESERVED.