Hi Ben, welcome to the forum!
What you need to do is setting up a connection to your SQL server and making a user defined variable.
Use this connection in the database task to execute your SQL statement.
Then you need a set variable task to get the output of the database task en assign this to your variable.
Good luck,
Erik
Uses Visualcron since 2006.