Click here to Skip to main content
14,333,606 members
Rate this:
Please Sign up or sign in to vote.
See more:
hi, i simlpy select value like

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
Rate this:
Please Sign up or sign in to vote.

Solution 1

You may use the SQL LIKE operator[^] in order to accept (or reject) a particular column format.
   
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..
Rate this:
Please Sign up or sign in to vote.

Solution 2

Check this one :
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.
   
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, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100