﻿CREATE PROCEDURE [session].[CreateSession]
	@InitialBoardStateDocument [session].[JsonDocument]
AS
BEGIN
	SET NOCOUNT ON

	INSERT INTO [session].[Session] ([Name], BoardState, Player1Id)
	SELECT
		JSON_VALUE(@InitialBoardStateDocument, '$.Name'),
		@InitialBoardStateDocument,
		Id
	FROM [user].[User]
	WHERE [Name] = JSON_VALUE(@InitialBoardStateDocument, '$.Player1');
END