Use switch_to_blog( $new_blog_id )
instead.
You can find the function in wp-includes/ms-blogs.php
.
Update
$wpdb->set_blog_id()
doesn’t change the global variable $blog_id
which is returned by get_current_blog_id()
. switch_to_blog()
does change the global variable.