user3885474
user3885474

Reputation: 401

How to check password length and chars

I have a password field (char type).

How can i make sure it contains exectly 8 chars between a-z and 0-9 only?

What kind of check() should i use?

Ty!

Upvotes: 0

Views: 992

Answers (1)

Gidil
Gidil

Reputation: 4137

Not sure it's a great idea to do this but try something along the lines of this:

DECLARE @test VARCHAR(10) = '123a*dzx' 

SELECT 1 
WHERE  Len(@test) = 8 
       AND @test NOT IN (SELECT @test 
                         WHERE  @test LIKE '%[^a-z0-9]%') 

You can try it out on SQL Fiddle

Upvotes: 3

Related Questions