Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Best method to disallow special characters
Message
 
 
À
04/10/2005 12:22:06
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Sécurité
Divers
Thread ID:
01055902
Message ID:
01055939
Vues:
26
This message has been marked as the solution to the initial question of the thread.
Here's the shorter and faster way to test for "bad" characters
DECLARE @BadCharList varchar(32), @StringToTest varchar(50)

SET @StringToTest = 'CHECK Constraint z'
SELECT PATINDEX('%[!@#$%^&*()]%',  @StringToTest)

-- or 

SET @BadCharList = '!@#$%^&*()'
SELECT PATINDEX('%[' + @BadCharList + ']%',  @StringToTest)
>The function would allow the code to be reused over several tables or even databases. It could be used in triggers.
>
<snip>>
>In a trigger or a CHECK Constraint there is still the issue of having to check each field for each special character. Can you think of a better, quicker way of doing this, or is this as good as another choice?
--sb--
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform