Share via


Scripting Events in the Workflow Designer for SQL Server

This content is no longer actively maintained. It is provided as is, for anyone who may still be using these technologies, with no warranties or claims of accuracy with regard to the most recent product version or service release.

To add script to a workflow process for SQL Server, first decide which event you want to use as the trigger for the script.

**Note   **If your script updates any rows, you must have an OnChange event on the state. You are not required to script the OnChange event, but it must exist to support any updates. If you do not want to leave the state when performing the updates, add a Transition Within to the state.

To add code to workflow events

  1. On the workflow process diagram, double-click the event icon for the event to which you want to add code. This opens the Code Editor and enters the Sub/End Sub tags for you.
  2. Enter the code for the event script procedure.
  3. If you want a validation script to run before the event is permitted, select the object name from the Object list at the top of the Code Editor window and the <eventname>Validate event from the Event list, and then add the script between the Function/End Function tags.
  4. If desired, add any additional functions or procedures associated with the workflow script.
  5. Click Verify Script on the Tools menu.

See Also

Scripting Workflow Events for SQL Server | When to Use Which Event | Data Manipulation Using Workflow Script | Error Handling for Workflow Script | Testing and Debugging in the Workflow Designer for SQL Server | Script Examples for SQL Server