Click here to Skip to main content
15,883,938 members
Please Sign up or sign in to vote.
3.00/5 (2 votes)
See more:
hi, i simlpy select value like

SQL
SELECT '345/576' as Test


now i want to check that

if '345/576' contain '/' then error else No Error.
Posted
Updated 5-Nov-13 0:33am
v2

You may use the SQL LIKE operator[^] in order to accept (or reject) a particular column format.
 
Share this answer
 
Comments
xibit89 5-Nov-13 5:52am    
can i generate error in this case, using CASE
CPallini 5-Nov-13 6:00am    
I dont' know if the DB you are using allows that (for instance SQL Server does provide RAISERROR). In any case you could report the error condition to the upper layer (if any).
xibit89 5-Nov-13 6:16am    
that's i m asking that how exactly i could implement error condition..
Check this one :
SQL
select case when charindex('/', '345/576')>0 then '345/576' else 'error' end

Replace '345/576' with a field name and add from statement and other things...

Hope its clear.
 
Share this answer
 
Comments
xibit89 5-Nov-13 7:20am    
Thanks.
Amir Mahfoozi 5-Nov-13 7:22am    
You're welcome.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900