Inside TFS database schema, shelvesets are saved in tbl_workspace table with type=1.
select * from tbl_Workspace where type = 1 ;
One of the ways to get ownerID is from a developer's workspace name.
select * from tbl_Workspace where WorkspaceName='MYWORKSPACENAME';
To change the owner of a shelveset, run the following command:
update tbl_Workspace set ownerid=5 where type = 1 and WorkspaceName='shelvetest_3';
This may be useful after a develop leaves the team and his Active Directory ID is revoked.
Note: It is highly recommended not to modify TFS database directly.