Click here to Skip to main content
15,893,668 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a MS SQL SERVER 2005 table with 4 columns, Col1, Col2, Col3 and Col4. If Col2 and Col3 are NULL, then Col4 should deny data that is inserted manually through GUI, which means no query is used either to Insert/Update. The work is done manually through GUI. Else if Col2 and Col3 are NOT NULL, then Col4 can accept data. I don't require Stored Procedures or Triggers to have this done.
Posted
Updated 28-Mar-12 18:39pm
v3
Comments
member60 28-Mar-12 1:15am    
you can use improve question question tag for editing the question instead of reposting it again.
[no name] 28-Mar-12 10:46am    
Please add more details like language / platform

You don't need a SP or a Trigger to achieve this, you can either use IF conditions or CASE[^] in your inline query

like
SQL
UPDATE TABLE1 SET COL4 = CASE COL1 IS NULL AND COL2 IS NULL THEN NULL ELSE 'New Value' END
 
Share this answer
 
If you don't want an SP or a Trigger, then you either have to submit it as a complete query - inefficient, and the same code as a SP would have been, or better do it in the GUI application.

Since you don't tell use what language, platform etc, you are using, we can't help you.
 
Share this answer
 
Comments
arunrk87 28-Mar-12 1:27am    
I use MS SQL SERVER 2005 and no Front-end applications.
[no name] 28-Mar-12 10:52am    
How do you pass the new value to DB? is by using UPDATE COMMAND?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900