Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Checking for upper,lower case, number and symbol

Author  Topic 

dumbdumb
Starting Member

5 Posts

Posted - 2004-03-17 : 20:24:42
Hi all

How do I ckeck whether there is upper case, lower case, symbol and number for an input parameter belonging to a store procedure.

Sorry for posting similar question again but I need urgent help!

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2004-03-17 : 20:27:37
I don't understand what you mean. Do you mean inside the variable (meaning data) or the variable name itself? Please provide an example.

Tara
Go to Top of Page

dumbdumb
Starting Member

5 Posts

Posted - 2004-03-17 : 20:49:02
Take the example below, How do I check whether the @strTest value contain at least one upper case, one lower case, one numeric, and lastly one non-alphanumeric character?


CREATE PROCEDURE AM_ValidatePwd
As
DECLARE @strTest as varchar(20)
SET @strTest = 'test test the water%1E'
Go
Go to Top of Page

byrmol
Shed Building SQL Farmer

1591 Posts

Posted - 2004-03-17 : 20:59:56
dumbdumb,

I take it that example equates to a failure....
Have you read the pattern matching section in BOL? If not, do so....
You will simply expand the expression I gave you before.....


DECLARE @T VARCHAR(1000)
SET @T = 'assfasD2fs^'

--OR
IF @T LIKE '%[abcdefgfhijklmnopqrstuvwxyz]%' COLLATE latin1_general_cs_as
AND @T LIKE '%[ABCDEFGHIJKLMNOPQRSTUVWXYZ]%' COLLATE latin1_general_cs_as
AND @T LIKE '%[0-9]%'
AND @T LIKE '%[^0-9a-Z]%'
PRINT 'OK'
ELSE
PRINT 'No'


DavidM

"An Ugg Boot is a generic Australian term that has been in use for nearly 100 hundred years. Now some coporate wanker has trademarked it.. "
Go to Top of Page

dumbdumb
Starting Member

5 Posts

Posted - 2004-03-17 : 22:06:34
Hi byrmol, Thanks, Solve my problem!
Go to Top of Page
   

- Advertisement -