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.
| Author |
Topic |
|
wkm1925
Posting Yak Master
207 Posts |
Posted - 2010-01-11 : 23:55:19
|
| I've table as followdeclare @tMyData table(TrnxID int,CardNo varchar(20),CardExpired datetime)1. I want CardExpired Field only allow the 1st day of the month can be inserted.How to create Contraint to control that? |
|
|
senthil_nagore
Master Smack Fu Yak Hacker
1007 Posts |
Posted - 2010-01-12 : 00:02:17
|
| ALTER TABLE @tMyData WITH CHECK ADD CONSTRAINT CK_tMyData CHECK ((datepart(day,[CardExpired])=(1)))ALTER TABLE @tMyData CHECK CONSTRAINT CK_tMyDataSenthil.C------------------------------------------------------[Microsoft][ODBC SQL Server Driver]Operation canceledhttp://senthilnagore.blogspot.com/ |
 |
|
|
wkm1925
Posting Yak Master
207 Posts |
Posted - 2010-01-12 : 00:06:55
|
| tq very much |
 |
|
|
senthil_nagore
Master Smack Fu Yak Hacker
1007 Posts |
Posted - 2010-01-12 : 00:15:14
|
| Welcome :)Senthil.C------------------------------------------------------[Microsoft][ODBC SQL Server Driver]Operation canceledhttp://senthilnagore.blogspot.com/ |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2010-01-12 : 01:38:07
|
quote: Originally posted by senthil_nagore ALTER TABLE @tMyData WITH CHECK ADD CONSTRAINT CK_tMyData CHECK ((datepart(day,[CardExpired])=(1)))ALTER TABLE @tMyData CHECK CONSTRAINT CK_tMyDataSenthil.C------------------------------------------------------[Microsoft][ODBC SQL Server Driver]Operation canceledhttp://senthilnagore.blogspot.com/
You can only alter permanent/temporary table not the table variableMadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|