Introduction
In this blog post, you will learn how to call MongoDB Shell Commands from SSIS using the MongoDB ExecuteSQL task
Some use cases for calling MongoDB shell commands are listed here.
How to call MongoDB Shell Commands in SSIS
- Download and install SSIS PowerPack from here
- From the toolbox of the SSIS designer, drag ZS MongoDB ExecuteSQL Task
- Click on New Connection (Next to the connection dropdown)
- Configure the MongoDB connection and click Test. Close UI by clicking OK
- Now, on the Task UI, configure it as below. Notice the “Examples” dropdown. That’s the best way to learn various commands.
- You can also use the “Insert Variables” option to make your command dynamic (Read value from SSIS variable)
Add MongoDB User
To add a MongoDB user using the MongoDB ExecuteSQL Task, use the following Script
|
1 2 3 4 5 6 |
{ scope: 'database', command: 'eval', db: 'Northwind', args: { code: 'db.createUser( { user: "myUser1", pwd: "password123",roles: [ "readWrite", "dbAdmin" ] })' } } |
Remove MongoDB User
To remove the MongoDB user using the MongoDB ExecuteSQL Task, use the following Script
|
1 2 3 4 5 6 |
{ scope: 'database', command: 'eval', db: 'Northwind', args: { code: 'db.removeUser("myUser1")' } } |
List MongoDB Users from the Command Line
To list existing users for a specific database, perform the following steps.
- Open the command prompt and type mongo
- If needed, type userid/password (if not required, then do the next step)
- type use YourDBName
- Type db.getUsers()


