Replace Password with asterisk in SQL Query

Last Reply on Jun 21, 2012 06:27 AM By vinayak

Posted on Jun 20, 2012 10:11 AM

my gird view consist of 3 columns login_id , username,password

i want do dislay 1 ,* ,*

instead of 1 , sohail.pass

in my grid view.

means i want to apply passwordchar to grid view .

 

Posted on Jun 21, 2012 06:27 AM

create Scalar function like

 

CREATE FUNCTION [dbo].[GetFormatedPass] (	@Pass NVARCHAR(256))
RETURNS NVARCHAR(256)ASBEGIN
DECLARE @i INT = 1, @formatedPass nvarchar(50) = '*', @PassLength int	 
SET @PassLength = LEN(@Pass)WHILE  @i<= @PassLength-1BEGIN 
SET @formatedPass = @formatedPass + '*'SET @i = @i + 1END 		
	RETURN @formatedPassEND
 

AND replace ur query like


 

SELECT Client_Login.CTax_Name, Client_Login.CLogin_Name, [dbo].[GetFormatedPass](Client_Login.CPassword) as CPassword, Client_Login.Secret_Question, Client_Login.Answer FROM Client_Login WHERE (((Client_Login.Client_ID)='" + CliID + "'))"