How to Create Folder from SQL Server sys.xp_create_subdir Extended Stored Procedure
In this SQL Server tutorial for SQL developers, I'll show T-SQL codes to create folder using SQL Server sys.xp_create_subdir extended stored procedure.
Here is the first sql xp_create_subdir example for SQL Server professionals.
In order to create file system directory successfully, access permissions for the SQL user must be granted correctly.
For example, in my SQL Server development environment, I have configured required permission for the "C:\SQLDatabases\" folder.
On the other hand when I set the xp_create_subdir argument as "C:\TestFolder\" for example,
In order to resolve Access is denied error related with xp_create_subdir usage, you should grant Write permission to SQLServerMSSQLUser (SQLServerMSSQLUser$SQLServerInstance) user.
You can use the Windows Explorer and grant required permission on the root folder where you want to create file folders using xp_create_subdir.
Giving Write permission is enough to create folder using sys.xp_create_subdir extended stored procedure.