SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Case Query
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

kshitizgp
Starting Member

31 Posts

Posted - 04/25/2012 :  11:26:14  Show Profile  Reply with Quote
suppose i already have an entry in db

Id--------------date-------strt--------end

vehicle---26/4/2012-----2pm-------4pm

now.. since there is already a data at a particular time there will be a conflict when i INSERT for the same time

like

Car---26/4/2012-----2pm-------4pm ---> this should only happen when vehicle includes -- car in it

same 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 Case

i DONT have any other way inorder to pass hardcoded values since this system is for one-time app ...

Lamprey
Flowing Fount of Yak Knowledge

3832 Posts

Posted - 04/25/2012 :  11:48:09  Show Profile  Reply with Quote
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.
Go to Top of Page

kshitizgp
Starting Member

31 Posts

Posted - 04/25/2012 :  13:28:52  Show Profile  Reply with Quote
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
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.05 seconds. Powered By: Snitz Forums 2000