Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Need help in validating users input value(from Screen)


Need help in validating users input value(from Screen)

Author
Message
JoNTSQLSrv
JoNTSQLSrv
SSC Rookie
SSC Rookie (35 reputation)SSC Rookie (35 reputation)SSC Rookie (35 reputation)SSC Rookie (35 reputation)SSC Rookie (35 reputation)SSC Rookie (35 reputation)SSC Rookie (35 reputation)SSC Rookie (35 reputation)

Group: General Forum Members
Points: 35 Visits: 134
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 Sad thanks in advance
Phil Parkin
Phil Parkin
SSCrazy Eights
SSCrazy Eights (8.4K reputation)SSCrazy Eights (8.4K reputation)SSCrazy Eights (8.4K reputation)SSCrazy Eights (8.4K reputation)SSCrazy Eights (8.4K reputation)SSCrazy Eights (8.4K reputation)SSCrazy Eights (8.4K reputation)SSCrazy Eights (8.4K reputation)

Group: General Forum Members
Points: 8356 Visits: 19491
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.

If the answer to your question can be found with a brief Google search, please perform the search yourself, rather than expecting one of the SSC members to do it for you.

Please surround any code or links you post with the appropriate IFCode formatting tags. It helps readability a lot.
JoNTSQLSrv
JoNTSQLSrv
SSC Rookie
SSC Rookie (35 reputation)SSC Rookie (35 reputation)SSC Rookie (35 reputation)SSC Rookie (35 reputation)SSC Rookie (35 reputation)SSC Rookie (35 reputation)SSC Rookie (35 reputation)SSC Rookie (35 reputation)

Group: General Forum Members
Points: 35 Visits: 134
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 Sad
Phil Parkin
Phil Parkin
SSCrazy Eights
SSCrazy Eights (8.4K reputation)SSCrazy Eights (8.4K reputation)SSCrazy Eights (8.4K reputation)SSCrazy Eights (8.4K reputation)SSCrazy Eights (8.4K reputation)SSCrazy Eights (8.4K reputation)SSCrazy Eights (8.4K reputation)SSCrazy Eights (8.4K reputation)

Group: General Forum Members
Points: 8356 Visits: 19491
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.

If the answer to your question can be found with a brief Google search, please perform the search yourself, rather than expecting one of the SSC members to do it for you.

Please surround any code or links you post with the appropriate IFCode formatting tags. It helps readability a lot.
JoNTSQLSrv
JoNTSQLSrv
SSC Rookie
SSC Rookie (35 reputation)SSC Rookie (35 reputation)SSC Rookie (35 reputation)SSC Rookie (35 reputation)SSC Rookie (35 reputation)SSC Rookie (35 reputation)SSC Rookie (35 reputation)SSC Rookie (35 reputation)

Group: General Forum Members
Points: 35 Visits: 134
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 ? Sad could you please show me some related example ?
Phil Parkin
Phil Parkin
SSCrazy Eights
SSCrazy Eights (8.4K reputation)SSCrazy Eights (8.4K reputation)SSCrazy Eights (8.4K reputation)SSCrazy Eights (8.4K reputation)SSCrazy Eights (8.4K reputation)SSCrazy Eights (8.4K reputation)SSCrazy Eights (8.4K reputation)SSCrazy Eights (8.4K reputation)

Group: General Forum Members
Points: 8356 Visits: 19491
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 ? Sad 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.

If the answer to your question can be found with a brief Google search, please perform the search yourself, rather than expecting one of the SSC members to do it for you.

Please surround any code or links you post with the appropriate IFCode formatting tags. It helps readability a lot.
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search