Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Check Constraint

Author  Topic 

Gom
Starting Member

4 Posts

Posted - 2009-04-26 : 02:16:26
TB01MS04EXAT200904241832061001
This is my AutoGenerate Key values on my table
i have to use the check constraint for this value
It has to check the first two letters
should be char next letter should be numeric
it has to check vice versa according to the value
i given above..How to create check constraint???


if i enter the numeric values instead of char
it will throw an error
error means
check constraint violation error



SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2009-04-26 : 03:30:24
Col1 LIKE '[a-zA-Z][a-zA-Z][0-9][0-9]%'



E 12°55'05.63"
N 56°04'39.26"
Go to Top of Page

dineshrajan_it
Posting Yak Master

217 Posts

Posted - 2009-04-28 : 00:30:39
or this

create table tab
(
tabid varchar(20) check(patindex('[a-z A-Z][a-z A-Z][0-9][0-9]%',tabid)>0)
)

its simillar one except replacing like statements into patindex

Iam a slow walker but i never walk back
Go to Top of Page
   

- Advertisement -