Last active
November 5, 2024 21:54
-
-
Save alefra88/89833a45cdfd62bd3d259f75d0ac5f92 to your computer and use it in GitHub Desktop.
sp en sql server para insertar usuario con password hasheada, se agregó mensaje de error
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
USE [DB_desde_transact] | |
GO | |
/****** Object: StoredProcedure [dbo].[spUsuariosInsertar] Script Date: 05/11/2024 03:52:16 p. m. ******/ | |
SET ANSI_NULLS ON | |
GO | |
SET QUOTED_IDENTIFIER ON | |
GO | |
ALTER PROCEDURE [dbo].[spUsuariosInsertar] | |
( | |
@Email varchar(250), | |
@Password varchar(30) | |
) | |
AS | |
BEGIN | |
SET NOCOUNT ON; | |
BEGIN TRY | |
DECLARE @PasswordHash varbinary(32); | |
SELECT @PasswordHash = HASHBYTES('SHA2_256', @Password); | |
INSERT INTO dbo.Usuarios(FechaAlta,Email,Password) | |
VALUES (GETDATE(), @Email, @PasswordHash) | |
END TRY | |
BEGIN CATCH | |
DECLARE @ErrorMessage NVARCHAR(4000); | |
SET @ErrorMessage = ERROR_MESSAGE(); | |
RAISERROR(@ErrorMessage, 16, 1); | |
END CATCH | |
END |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment