Category Archives: SQL Server

The Console Handshake โ€” Validating Hikvision iVMS-4200 SQL Sync

Purpose: To document the full ritual of integrating Hikvision iVMS-4200 with SQL Server, ensuring future resilience and communal clarity.

๐Ÿ”ง Phase 1: SQL Server Preparation

1. Enable TCP/IP and Port 1433

  1. Open SQL Server Configuration Manager
  2. Navigate to SQL Server Network Configuration โ†’ Protocols for MSSQLSERVER
  3. Right-click TCP/IP โ†’ Enable
  4. Double-click TCP/IP โ†’ go to IP Addresses tab
  5. Scroll to IPAll section โ†’ set TCP Port = 1433
  6. Click OK and restart the SQL Server service

Verify SQL Server is listening on the correct port:

SQL
SELECT local_net_address, local_tcp_port
FROM sys.dm_exec_connections
WHERE local_tcp_port IS NOT NULL;

2. Enable Mixed Mode Authentication

  1. Open SQL Server Management Studio
  2. Right-click your server name โ†’ Properties
  3. Go to Security tab
  4. Select SQL Server and Windows Authentication mode
  5. Click OK and restart the SQL Server service

Confirm Mixed Mode is active:

SQL
EXEC xp_instance_regread
  N'HKEY_LOCAL_MACHINE',
  N'Software\Microsoft\MSSQLServer\MSSQLServer',
  N'LoginMode';

If the result is 2, Mixed Mode is enabled โœ…

3. Test Manual Connection

CMD
sqlcmd -S 192.168.1.10,1433 -U sa -P [PASSWORD]

๐Ÿ”ฅ Phase 2: Windows Firewall Verification

Create a firewall rule to allow SQL Server traffic:

PowerShell
New-NetFirewallRule -DisplayName "SQL Server 1433 Inbound" -Direction Inbound -Protocol TCP -LocalPort 1433 -Action Allow

๐Ÿง  What This Command Does

  • Creates a new rule named SQL Server 1433 Inbound
  • Direction: Inbound โ€” allows incoming traffic
  • Protocol: TCP โ€” used by SQL Server
  • LocalPort: 1433 โ€” the default SQL Server port
  • Action: Allow โ€” permits traffic through the firewall

๐Ÿงฑ Phase 3: Table Schema Alignment

Step 1: Create the Database

SQL
CREATE DATABASE Attendance;

Step 2: Switch to the Database

SQL
USE Attendance;

Step 3: Create the Table

SQL
CREATE TABLE TimeAttendance (
  ATTENDANCE_id INT,
  ATTENDANCE_date_time DATETIME,
  ATTENDANCE_date DATE,
  ATTENDANCE_time TIME,
  ATTENDANCE_direction NVARCHAR(10),
  ATTENDANCE_device NVARCHAR(50),
  ATTENDANCE_serial NVARCHAR(50),
  ATTENDANCE_name NVARCHAR(100),
  ATTENDANCE_card NVARCHAR(50)
);

Step 4: Verify Field Names

SQL
SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_NAME = 'TimeAttendance';

๐Ÿงช Optional Verification Query: Confirming sa Access

To verify that the built-in sa login is mapped to the database:

SQL
SELECT name, type_desc
FROM sys.database_principals
WHERE name = 'sa';

If this query returns a row, sa is explicitly mapped. If not, it still has full access via sysadmin role unless denied.

๐Ÿงช Phase 4: Profiler-Based Validation

  1. Launch SQL Server Profiler
  2. Filter by LoginName = sa and DatabaseName = Attendance
  3. Click Save in iVMS-4200
  4. If no activity: internal block
    If activity appears: SQL handshake confirmed โœ…

๐Ÿ”„ Phase 5: Console Reset

  1. Exit iVMS-5200 Service Management from system tray
  2. Open Hikvision Watchdog and restart all services
  3. Close and reopen iVMS-4200 Client
  4. Create a new Third-Party DB profile
  5. Use updated IP: 192.168.1.10
  6. Click Save โ€” success message appears ๐ŸŽ‰

๐Ÿง  Optional Enhancements

  • Install SQL Server Native Client
  • Monitor inserts with triggers or logs
  • Begin device-level sync once console config is validated

This scroll is now part of the Kapothi Vault โ€” a communal artifact of sovereign troubleshooting and digital mastery.

Continue reading The Console Handshake โ€” Validating Hikvision iVMS-4200 SQL Sync

How to open the firewall port for SQL Server on Windows Server 2008/R2

๐Ÿชถ Manual Method (Windows Firewall GUI)

Step 1: Open Control Panel โ†’ Windows Firewall โ†’ Advanced Settings.

Step 2: Click Inbound Rules โ†’ New Rule.

Step 3: Select Port, then choose TCP.

Step 4: Enter 1433 (default SQL Server port).

Step 5: Choose Allow the connection.

Step 6: Apply to Domain, Private, Public profiles as needed.

Step 7: Name the rule SQL Server Port 1433 and finish.

๐Ÿชถ Automated Method (BAT File)

Save the following as OpenSQLPort.bat and run as Administrator:

@echo off
REM === Open SQL Server port on Windows Firewall ===
set PORT=1433
set RULE_NAME="SQL Server Port %PORT%"

netsh advfirewall firewall add rule name=%RULE_NAME% ^
    dir=in action=allow protocol=TCP localport=%PORT%

pause
    

๐Ÿชถ How It Works

  • set PORT=1433 โ†’ Default SQL Server port (change if needed).
  • netsh advfirewall firewall add rule โ†’ Creates inbound rule.
  • protocol=TCP localport=%PORT% โ†’ Opens the port for SQL traffic.
  • pause โ†’ Keeps window open for confirmation.

๐Ÿชถ Notes

โš ๏ธ Security Tip: If you want to restrict access, add:

remoteip=192.168.1.100

This limits SQL connections to a specific server IP.

๐Ÿ—‘๏ธ To remove the rule later:

netsh advfirewall firewall delete rule name="SQL Server Port 1433"

๐Ÿ” Connectivity Test: After opening the port, confirm with:

telnet SERVERNAME 1433

If the connection opens, the firewall rule is working.

Applies to
  • Microsoft SQL Server 2005 Developer Edition
  • Microsoft SQL Server 2005 Enterprise Edition
  • Microsoft SQL Server 2005 Standard Edition
  • Microsoft SQL Server 2008 Developer
  • Microsoft SQL Server 2008 Enterprise
  • Microsoft SQL Server 2008 Standard
  • Microsoft SQL Server 2008 Web
  • Windows Server 2008 Datacenter without Hyper-V
  • Windows Server 2008 Enterprise without Hyper-V
  • Windows Server 2008 for Itanium-Based Systems
  • Windows Server 2008 Standard without Hyper-V
  • Windows Server 2008 Datacenter
  • Windows Server 2008 Enterprise
  • Windows Server 2008 Standard
  • Microsoft SQL Server 2008 R2 Developer
  • Microsoft SQL Server 2008 R2 Enterprise
  • Microsoft SQL Server 2008 R2 Standard
  • Microsoft SQL Server 2008 R2 Web
  • SQL Server 2012

source – http://support.microsoft.com/kb/968872