Pages

Monday 12 July 2021

How to Do Case Sensitive String Match in SQL server

 CREATE PROCEDURE [dbo].[tblUserSelect_Authenticate]

@Username nvarchar(50),
@Password nvarchar(50)
AS
BEGIN
SELECT * FROM tblUser WHERE Username = @Username AND Password = @Password COLLATE SQL_Latin1_General_CP1_CS_AS
END

To tell SQL do a case-sensitive search, we will modify the above procedure as below. Please note we added a “COLLATE SQL_Latin1_General_CP1_CS_AS” to the field we want an exact match for.

No comments:

Post a Comment