Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Need help in validating users input value(from Screen) Expand / Collapse
Author
Message
Posted Friday, August 2, 2013 3:22 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Monday, November 24, 2014 10:17 AM
Points: 8, Visits: 47
Hi guys ,

Urgently i am in need of validating a input variable comes from screen i.e., i have to throw error or raiserror if the user have does not entered the vale in a particular format

for example,

The value should be in this format 'HG#1,MWR#1.5' i.e., the value should start with Alphabets followed by '#' followed by number(1-9) or decimal(1.5 after decimal pot only 5 has to come) followed by ',' then alphabet then '#' then number or decimal ext without any space in between .


So possible values :

1.HG#1
2. HG#1,MWR#1.5
3. HG#1,MWR#1.5,'somealpabet#number'........

sorry for my english . Hope every one might understand my request and give a perfect solution.

so please help me thanks in advance
Post #1480311
Posted Friday, August 2, 2013 3:30 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Today @ 2:15 AM
Points: 5,317, Visits: 12,354
Presumably you are using some sort of front-end application (Winform/Web) to get this info from the user. This validation should be done there and not by SQL Server.


Help us to help you. For better, quicker and more-focused answers to your questions, consider following the advice in this link.

When you ask a question (and please do ask a question: "My T-SQL does not work" just doesn't cut it), please provide enough information for us to understand its context.

It is better to keep your mouth shut and appear stupid than to open it and remove all doubt. (Mark Twain)
Post #1480313
Posted Friday, August 2, 2013 3:43 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Monday, November 24, 2014 10:17 AM
Points: 8, Visits: 47
Phil Parkin (8/2/2013)
Presumably you are using some sort of front-end application (Winform/Web) to get this info from the user. This validation should be done there and not by SQL Server.


Thanks a lot for your reply . what ever you are saying is correct , but in our company we put all the validation from SQL Server, using SP(stored procedure). SO that if the requirement is changed we can easily edit the SP. So please help me sir
Post #1480318
Posted Friday, August 2, 2013 3:55 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Today @ 2:15 AM
Points: 5,317, Visits: 12,354
I see.

You can probably get quite close through the use of PATINDEX and diligent use of wildcards. Have you tried this?



Help us to help you. For better, quicker and more-focused answers to your questions, consider following the advice in this link.

When you ask a question (and please do ask a question: "My T-SQL does not work" just doesn't cut it), please provide enough information for us to understand its context.

It is better to keep your mouth shut and appear stupid than to open it and remove all doubt. (Mark Twain)
Post #1480319
Posted Friday, August 2, 2013 4:34 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Monday, November 24, 2014 10:17 AM
Points: 8, Visits: 47
Phil Parkin (8/2/2013)
I see.

You can probably get quite close through the use of PATINDEX and diligent use of wildcards. Have you tried this?


PATINDEX is just retrieving the index value , but how come this will validate the user input value ? could you please show me some related example ?
Post #1480327
Posted Friday, August 2, 2013 5:12 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Today @ 2:15 AM
Points: 5,317, Visits: 12,354
JoNTSQLSrv (8/2/2013)
Phil Parkin (8/2/2013)
I see.

You can probably get quite close through the use of PATINDEX and diligent use of wildcards. Have you tried this?


PATINDEX is just retrieving the index value , but how come this will validate the user input value ? could you please show me some related example ?


..And if the desired pattern is not found, it will return zero. That is how you test. You can apply repeated tests to look for different things in your proc, if necessary.

There are thousands, if not millions, of examples on the Internet if you take the time to search for them.



Help us to help you. For better, quicker and more-focused answers to your questions, consider following the advice in this link.

When you ask a question (and please do ask a question: "My T-SQL does not work" just doesn't cut it), please provide enough information for us to understand its context.

It is better to keep your mouth shut and appear stupid than to open it and remove all doubt. (Mark Twain)
Post #1480335
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse