 
 BEGIN
 
-	SET NOCOUNT ON
-
-	INSERT INTO AccountTable([name], [password], [createTime], [win], [lose], [isValid]) VALUES (@name, @password, GETDATE(), 0, 0, 1)
-
-	SELECT @@IDENTITY
+	SELECT * FROM AccountTable where [name] = @name
+
+	IF @@ROWCOUNT != 0
+
+	BEGIN
+
+		SELECT 0
+
+	END
+
+	ELSE
+
+	BEGIN
+
+		SET NOCOUNT ON
+
+		INSERT INTO AccountTable([name], [password], [createTime], [win], [lose], [isValid]) VALUES (@name, @password, GETDATE(), 0, 0, 1)
+
+		SELECT @@IDENTITY
+
+	END
 
 END
 


EXEC spCreateAccount 'test3', '12345'

EXEC spCreateAccount 'test4', '12345'

CREATE PROCEDURE [dbo].[spLoadPlayer]

	@name	NVARCHAR(255),

	@password NVARCHAR(255)

AS

BEGIN

	SET NOCOUNT ON

	SELECT [playerUID], [win], [lose], [elo], [isValid], [comment] FROM AccountTable WHERE [name] = @name AND [password]=@password AND isValid = 1

END		   

