title: Getting the current user in SQL Server stored procedure
body: <p>I have a SQL Server 2008 Express R2 instance authenticating from Active Directory. Users have records associated with their AD account stored in a database. I would like to have stored procedures for them to retrieve their records.</p>
  
  <p>So the procedure might make the query <code>SELECT * FROM PurchaseOrders WHERE uid = $userid</code></p>
  
  <p>How do I find out <code>$userid</code>, a property in their AD profile?</p>
  
  <p>Thanks!</p>