Synthetic Data — MSSQL
The Demo Factory dataset for MSSQL contains a single table for testing the MSSQL connection in Pirivision. For comprehensive analytics queries use the PostgreSQL dataset.
Created Table
The table is created in a separate schema named demo_fabrika; it will not conflict with your existing database objects.
-- Create schema if it does not exist
IF NOT EXISTS (SELECT 1 FROM sys.schemas WHERE name = 'demo_fabrika')
EXEC ('CREATE SCHEMA demo_fabrika');
GO
CREATE TABLE demo_fabrika.vardiya_uretim (
ts date NOT NULL,
hat_id nvarchar(20) NOT NULL,
makine_id nvarchar(20) NOT NULL,
vardiya nvarchar(10) NOT NULL,
urun_ailesi nvarchar(20) NOT NULL,
uretim_adet int NOT NULL,
hedef int NOT NULL
);
Data Generation Logic
Because T-SQL has no generate_series, the date sequence is built with a recursive CTE. The generated rows are multiplied by cross-joining with the machine and shift lists.
;WITH gun_serisi AS (
-- Starting point: 30 days before today
SELECT CAST(DATEADD(day, -30, GETDATE()) AS date) AS gun
UNION ALL
-- Each step advances one day
SELECT DATEADD(day, 1, gun)
FROM gun_serisi
WHERE gun < CAST(GETDATE() AS date)
),
makineler AS (
SELECT idx FROM (VALUES (1),(2),(3),(4),(5),(6)) AS m(idx)
),
vardiyalar AS (
SELECT v FROM (VALUES (N'V1'),(N'V2'),(N'V3')) AS x(v)
)
INSERT INTO demo_fabrika.vardiya_uretim
(ts, hat_id, makine_id, vardiya, urun_ailesi, uretim_adet, hedef)
SELECT
g.gun,
CASE WHEN m.idx <= 3 THEN N'HAT-1' ELSE N'HAT-2' END,
N'M0' + CAST(m.idx AS nvarchar(1)),
v.v,
-- Random product family per row via NEWID()
(SELECT TOP 1 u
FROM (VALUES (N'Product-A'),(N'Product-B'),(N'Product-C'),(N'Product-D')) x(u)
ORDER BY NEWID()),
250 + ABS(CHECKSUM(NEWID())) % 200, -- production count 250–449
400 -- fixed target
FROM gun_serisi g
CROSS JOIN makineler m
CROSS JOIN vardiyalar v
OPTION (MAXRECURSION 100);
Result: 31 days × 6 machines × 3 shifts = 558 rows
Loading into the Database
Run the SQL script against your database:
Running the script again is safe — the existing table is dropped first if it exists.
Adding to Pirivision
- Go to Port → New Data Source → MSSQL.
- Enter the server, database, and credentials.
- Click Test and Save to store the connection.
Once saved, an example query you can write in Compass: