I have one table that contains several tasks which is belongs to some categories and one column called 'completed' which tells particular task is completed or not, based on this status I want to update as 'completed' for particular category in another table which contains categories. How to do in MS SQL query? Here, for 'completed' column I am using bit as datatype.
Asked
Active
Viewed 136 times
0
-
2Could you provide the table schema and some sample data and expected result? – Felix Pamittan Apr 06 '15 at 04:40
2 Answers
0
You may create a AFTER INSERT TRIGGER on your first table thus you can update your second table column value referencing your status column value in the earlier.

Shyju
- 203
- 1
- 5
0
Update table category set complete = True where name In
(
select distinct t.category
from task t
where task.complete = true And not exists (
select t1.category
from task t1
where t1.category = t.category And t1.complete = false
)
)

InformedA
- 179
- 1
- 9
-
I want to update two table based on single button click from webpage. How to do in single stored procedure? . plz consider above same scenario. – Tarun Apr 06 '15 at 09:18
-
@Tarun I think you should try to update one table at a time. And you wrap the two queries updating the two tables in a transaction. – InformedA Apr 06 '15 at 10:37