Skip to main content
Question

Get current branch_id?

  • March 27, 2026
  • 1 reply
  • 6 views

Forum|alt.badge.img+1

There is no function for getting the current branch_id right?

 

In dynamic model code, the parameters @model_id and @branch_id are provided. In the full staged control procedure code I do not see how they are obtained.

 

I want to write a script, not dynamic code, and use the SF and IAM DB, so I need to filter by branch_id.

Is this a reliable way of getting the branch_id of the DB you are currently connected to: 

SELECT TOP 1 SF_BRANCH FROM sf_model_info ORDER BY sf_model_info_id desc

unless you start changing the connections between branches and databases, i guess

 

1 reply

Tim de Lang
Moderator
Forum|alt.badge.img+4
  • Moderator
  • March 27, 2026

Hi ​@Robin Liu,

Could you specify exactly what you want to achieve and where you’re looking to add the script?

Generally the model and branch id’s are provided to you as parameters, given you work in the context of a model and branch.

Is this a reliable way of getting the branch_id of the DB you are currently connected to: 

SELECT TOP 1 SF_BRANCH FROM sf_model_info ORDER BY sf_model_info_id desc

That will tell you what the branch name of the SF itself is. I assume you want information about your model and branch, not that of the SF?

Thanks,

Tim de Lang