﻿CREATE PROCEDURE [session].[SetPlayer2]
	@SessionName [session].[SessionName],
	@Player2Name [user].[UserName] NULL
AS
BEGIN
	SET NOCOUNT ON;

	DECLARE @player2Id BIGINT;
	SELECT @player2Id = Id FROM [user].[User] WHERE [Name] = @Player2Name;

	UPDATE sess
	SET Player2Id = @player2Id
	FROM [session].[Session] sess
	WHERE sess.[Name] = @SessionName;

END
