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 |
Arunraj
Starting Member
18 Posts |
Posted - 2015-01-06 : 06:01:10
|
Hi Friends,I need a help from you.THe Scenario is We have Tables like parent and Child Table.Like we have Child Table as Name AcademyContacts,In that we have Columns like Guid(PK)Not Null,AcademyId(FK), Not Null,Name,NullWorkPhone,NullCellPhone,NullEmail Id,NullOther.NullSince we have given Null to ''Workphone'',''Cellphone '', ''Email ID''.when inserting the data into these table if the particular columns are empty while inserting also the data will get populate into the table.AndI need is if these columns are ''Workphone'',''Cellphone'' , ''Email ID'' they cant insert the data into table.Like it must trigger like ''Please enter atleast one of these ''Workphone'',''Cellphone'' , ''Email ID'' columns.How to do this in triggers please suggests me friends !!!!I am waiting for your response !!! |
|
ahmeds08
Aged Yak Warrior
737 Posts |
Posted - 2015-01-06 : 06:17:06
|
it would be better to do this in your application codeJaveed Ahmedhttps://www.linkedin.com/pub/javeed-ahmed/25/5b/95 |
|
|
Arunraj
Starting Member
18 Posts |
Posted - 2015-01-06 : 06:33:06
|
Hi,Thank yu for your reply.I know very well we can use it in Stored Procedure as well as when we are creating a UI . But my Manager told to create a Triggers for this.Thats Y I have posted.quote: Originally posted by ahmeds08 it would be better to do this in your application codeJaveed Ahmedhttps://www.linkedin.com/pub/javeed-ahmed/25/5b/95
|
|
|
sz1
Aged Yak Warrior
555 Posts |
Posted - 2015-01-06 : 08:25:27
|
Seems a bit overkill for validation, why dont you add a check to the fields?ALTER TABLE AcadmenyContacts ADD CHECK (Workphone is not null)We are the creators of our own reality! |
|
|
ahmeds08
Aged Yak Warrior
737 Posts |
Posted - 2015-01-06 : 08:30:47
|
You can suggest your manager that,for every field check your app needs to hit the database which will be a over head.You need to avoid triggers as much as you can.Javeed Ahmedhttps://www.linkedin.com/pub/javeed-ahmed/25/5b/95 |
|
|
|
|
|
|
|