日期:2014-05-17 浏览次数:20379 次
update Man
set TaskID=case when TaskIdd is null then @manID else TaskID end,
TaskIdd=case when (TaskID is null and TaskIdd is null) then TaskIdd else @manID end
UPDATE Man SET TaskId = CASE WHEN TaskId IS NULL THEN @TaskId
ELSE TaskId END,
TaskIdd = CASE WHEN TaskId IS NULL THEN TaskIdd
ELSE CASE WHEN TaskIdd IS NULL THEN @TaskId
ELSE TaskIdd END END
WHERE ID = @ManId
IF EXISTS (SELECT 1 FROM Man WHERE ID = @ManId AND TaskId IS NULL)
BEGIN
UPDATE MAN SET TaskId = @TaskId WHERE ID = @ManId AND TaskId IS NULL
END
IF EXISTS (SELECT 1 FROM Man WHERE ID = @ManId AND TaskId IS NOT NULL AND TaskIdd IS NULL)
BEGIN
UPDATE Man SET TaskIdd = @TaskId WHERE ID = @ManId AND TaskId IS NOT NULL AND TaskIdd IS NULL
END