I don't know the answer to where it goes. But why not check if the database already exists first?

Move "Select db_id (?) AS [Database ID]" to sSQL

We use parameterized queries so the ? is the database name. If the returned value = 0 then it doesn't exist.

Also are you sure you need to switch to [master] ? We don't do this in our utility to do database creation/restore.