title: Microsoft SQL Server 2012: How to Insert record into relational tables
body: <p>is there a way to insert a record into relational tables and not to run query for each table? </p>
  
  <p>I need to insert a new log: l_WinUser, l_Status, t_StartTime, t_StartDate where username = username, g_Exe = g_Exe</p>
  
  <p>And if so is there a way in .NET to get the inserted record ID? Currently I am executing another query to retrieve the inserted log (works fine):</p>
  
  <pre><code>SELECT TOP (1) Logs.l_LogID 
  FROM Logs 
  INNER JOIN Game ON Logs.g_GameID = Game.g_GameID 
  INNER JOIN Member ON Logs.m_MemberID = Member.m_MemberID 
  WHERE (Game.g_Exe = @exe) 
  AND (Member.m_Username = @username) 
  AND (Logs.l_WinUser = @winUser)
  ORDER BY Logs.l_LogID DESC
  </code></pre>
  
  <p>Here's the ERD:</p>
  
  <p><img src="https://i.stack.imgur.com/rIkMc.png" alt="erd"></p>
  
  <p>Thank you so much.</p>