
How to create a new Dynamics NAV User from PowerShell
Current Windows User must have admin permission to the SQL Server

Table locking is a normal but often confusing reality in any multi-user ERP system. In Microsoft Dynamics NAV, locking issues are especially common in manufacturing and service-based organisations, particularly during month-end processing.
Table locking is a normal but often confusing reality in any multi-user ERP system. In Microsoft Dynamics NAV, locking issues are especially common in manufacturing and service-based organisations, particularly during month-end processing.
At month end, finance teams post large volumes of transactions—such as G/L Entries, Item Ledger Entries, and Value Entries—which increases database activity. When multiple users attempt to update the same tables at the same time, SQL Server may place locks to protect data consistency.
This is when users start asking:
This article explains:
When a user posts a transaction in NAV, SQL Server must ensure that data remains accurate and consistent.
To do this, SQL Server temporarily locks rows, pages, or entire tables while changes are being made.
If another user tries to access the same data at the same time, SQL Server may:
This is called blocking, and it is not a bug—it is a safety mechanism.
The fastest way to see blocking activity is through SQL Server Management Studio (SSMS).
EXEC sp_who2;This command shows all active SQL sessions.
The most important column is:
Once you locate the SPID shown in the BlkBy column, you now know which session is holding the lock.
Before taking technical action:
This information is extremely valuable if the issue keeps happening.
Sometimes the user:
In these cases, you have two technical options.
✅ This is the safest method when NAV access is available.
If NAV access is not possible, you can terminate the SQL session directly.
KILL <SPID>;Example:
KILL 57;⚠️ Important notes:
SELECT
r.session_id,
r.blocking_session_id,
r.status,
r.wait_type,
r.wait_time,
r.wait_resource,
s.login_name,
s.host_name,
s.program_name
FROM sys.dm_exec_requests r
JOIN sys.dm_exec_sessions s
ON r.session_id = s.session_id
WHERE r.blocking_session_id <> 0;This query shows:
SELECT
resource_type,
resource_associated_entity_id,
request_mode,
request_status
FROM sys.dm_tran_locks;Use this to identify:
SELECT
s.session_id,
t.text
FROM sys.dm_exec_requests r
JOIN sys.dm_exec_sessions s ON r.session_id = s.session_id
CROSS APPLY sys.dm_exec_sql_text(r.sql_handle) t
WHERE r.blocking_session_id <> 0;This is extremely useful when diagnosing custom code issues.
Dynamics NAV has some unique behaviours that increase locking risk.
Posting processes often lock:
These tables are high-contention tables, especially during month end.
In custom C/AL code:
COMMIT hold locks longer Reports like:
Should never run during peak usage.
Background jobs running via NAS can:
Proper scheduling is critical.
Older customisations:
Locking in Dynamics NAV is normal—but uncontrolled locking is avoidable.
By:
You can resolve issues quickly and prevent them from recurring.

Premanath Kumarage
Author

Current Windows User must have admin permission to the SQL Server

By default which database to connect is stored in a config file called ClientUserSettings.Config file.

Once the Log File has been truncated, run the below command to put it back the database into full recovery mode using below statement;
Start here
A working session, not a sales call. Bring the process your current system fights you on, and we will tell you plainly what it would take to fix it.
Newsletter
Stay ahead with Microsoft Business Applications.
Insights, implementation advice and practical ideas to help your business get more from Microsoft technology.
By subscribing, you acknowledge MicroCloud 360’s Privacy Policy.