At login time, a session is assigned to a temporary database, which remains in effect for the duration of that session and cannot change. Bindings are read from sysattributes, and are chosen according to these parameters:
If binding of type LG (login) exists, use that binding.
If binding of type AP (application name)exists, use that binding.
Bind session to a temporary database within the default group.
Bindings can be hard or soft:
Soft bindings – logins never fail despite any failures to assign a temporary database to the session according to the binding in effect. When all else fails, a session should always end up being assigned to the system tempdb.
Hard bindings – if an assignment of a temporary database to a session cannot be made according to the binding in effect, the login fails.