Database
SQL Server
Execute command
6 min
query vs commands there's a basic difference between them commands modify the data, and queries retrieve the data use this action to execute a sql command in microsoft sql first of all, you'll have to enter credentials for the execute command action you can find out how to do that https //docs procesio com/sql credential how to configure the execute command action? go to the process designers section and open a new or an existing process actions configuration can be performed once they are dragged and dropped on canvas step 1 drag the execute command action from toolbar and drop it on canvas; click on the action to open the properties panel step 2 you can edit the action name step 3 select a credential for the database server https //docs procesio com/sql credential step 4 click on execute command (not configured) card to go to the configurations steps step 5 type your sql query in the editor note you can always add process variables to your query press insert/ctrl+i (windows) or cmd+i (mac) step 6 add the output variable note it has to be defined as a single value object/integer in the output variable, you will see the number of rows affected by the executed command add the output variable step 7 save , validate and run the process step 8 click check instance to view the results based on our command, 2 rows were affected note using sql parameters when writing sql commands in execute command , you can use sql parameters to safely send values from your process to the database instead of inserting variables directly in the sql command, define parameters and map them to values in the configuration panel (as shown in the screenshots above) for example, instead of writing insert into clients (firstname, email) values ('{{client firstname}}', '{{client email}}') you can use parameters insert into clients (firstname, email) values (@firstname, @email) then map the parameters in the action configuration parameter sql type value firstname nvarchar {{client firstname}} email nvarchar {{client email}} using parameters helps you avoid sql syntax errors caused by special characters like ' reduce the risk of sql injection simplify sql commands that use process variables make workflows easier to maintain if a parameter value is null , procesio automatically sends a sql null value to the database
