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.
| Author |
Topic |
|
raju123
Starting Member
1 Post |
Posted - 2010-12-03 : 11:33:20
|
| I have a requirement to create a User Defined Function (UDF) for PIN that can accommodate the following 3 rules 1.Pin Should Contain number (0-9) characters (a-z,A-Z), and a limited number of special characters as following:~ ! $ # ^ * _ = { } [ ] : ? . , (space is not an allowed character)2.Pin Should be case-sensitive3. Pin Should Include at least one letter and one numberTable Structure : CREATE TABLE [dbo].[pin_sample] ( [Pin] [nvarchar] (50) NULL )Sample Data:Insert Into [pin_sample] (Pin)SELECT 'Moghaffar82!'union allSELECT 'SEMOrana1999'union allSELECT 'Seham011'union allSELECT 'InAsq8MO'union allSELECT 'Ziklin567'union allSELECT 'Yusuf123'union allSELECT 'hardstuFF12'union allSELECT 'Rxfv1p13'union allSELECT 'A#10frica'union allSELECT 'Waeeed1974'-- Rule #3 DECLARE @pin nvarchar (50), @error varchar (500)IF patindex('%[a-z]%',@Pin) > 0 and patindex('%[0-9]%',@Pin) > 0BEGIN Select 'Pin has atleast one charecter and one number'ENDELSE Select @error = 'Invalid Pin'I need T sql Codes for Rule#1 and Rule#2Your Help will be greatly appreciated.. |
|
|
nigelrivett
Master Smack Fu Yak Hacker
3385 Posts |
Posted - 2010-12-03 : 11:40:15
|
| 1 something likenot like '%[^~!$#\^*_={}\[\]:?.,0-9a-zA-Z]%' escape '\'2. That's to do with the checking not the pin itself.==========================================Cursors are useful if you don't know sql.SSIS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
|
|
|
|