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 |
|
kshitizgp
Starting Member
31 Posts |
Posted - 2012-04-25 : 11:26:14
|
| suppose i already have an entry in dbId--------------date-------strt--------endvehicle---26/4/2012-----2pm-------4pmnow.. since there is already a data at a particular time there will be a conflict when i INSERT for the same timelike Car---26/4/2012-----2pm-------4pm ---> this should only happen when vehicle includes -- car in itsame goes for auto --AUTO---26/4/2012-----2pm-------4pm ---> insert ... for that i have to loop in case condition BUT when i go for 'bike'bike---26/4/2012-----2pm-------4pm ---> THis should Not happen as vehicle doesnt include bike in Casei DONT have any other way inorder to pass hardcoded values since this system is for one-time app ... |
|
|
Lamprey
Master Smack Fu Yak Hacker
4614 Posts |
Posted - 2012-04-25 : 11:48:09
|
| If you can't fix your schema, there are a couple of options:1. You can do you data access through sproc(s). That way you can check for this condition and not allow the insert.2. You can implement a trigger to implement this constraint. |
 |
|
|
kshitizgp
Starting Member
31 Posts |
Posted - 2012-04-25 : 13:28:52
|
| IT WOUld be helpful if u give me a simple example .... i would really appreciate it .. just simple sql stmts as to how to do it .. i have 8 cases all hardcoded so please .. thanku |
 |
|
|
|
|
|