| Author |
Topic |
|
jszulc
Yak Posting Veteran
66 Posts |
Posted - 2010-04-15 : 06:06:04
|
| Hello there, In an update statement below I would like to include automatic cloning of a record (INSERT into KPITBL) when WHEN @Status = 'Completed' And @Activity='Logical Decom' and ProjectType='T433'Every column should be cloned automatically with the exception of "Project Type" which will be cloned as 'Decom' value and Activity set to 'CLONE', can this be done in this statement below or do I need a seperate insert or perhaps trigger on a table?UPDATE KPITbl SET Manager = @Manager, Lead = @Lead, WRM = @WRM, PRIME = @PRIME, PAR = @PAR, PMO = @PMO, RequestingLOB = @RequestingLOB, LOB = @LOB, PropertyIDStartLoc = @PropertyIDStartLoc, TspanID = @TspanID, SDMSRec = @SDMSRec, RequestID = @RequestID, PropertyIDFinishLoc = @PropertyIDFinishLoc, Description = @Description, ProjectType = @ProjectType, ServerName = @ServerName, ServerType = @ServerType, DCOorSTANDALONE = @DCOorSTANDALONE, TechAnalyst = @TechAnalyst, Status = @Status, RAG = CASE WHEN @Status = 'Completed' THEN 'C' WHEN @Status = 'Cancelled' THEN 'C' ELSE @RAG END, StartDates = @StartDates, EstimatedCompletionDate = @EstimatedCompletionDate, ActualCompletionDate = @ActualCompletionDate, Activity = @Activity, TreeorDomainImpacted = @TreeOrDomainImpacted, NumOfSites = @NumOfSites, NumOfUsers = NumOfUsers + @NumOfUsers, GBdatamoved = GBdatamoved + @GBdatamoved, GBdatadeleted = GBdatadeleted + @GBdatadeleted, NumOfSrvrsAdded = @NumOfSrvrsAdded, EUTEngineeringConsult = @EUTEngineeringConsult, TimeSpend = @TimeSpend, GBdatamovedPlanned = @GBdatamovedPlanned, NumOfUsersPlanned = @NumOfUsersPlanned, Complexity = @Complexity, ECM = @ECM, LastUpdated = GETDATE(), StatusCompletedDate = CASE WHEN @Status = 'Completed' THEN ISNULL([StatusCompletedDate] , GETDATE()) END, StatusCancelledDate = CASE WHEN @Status = 'Cancelled' THEN ISNULL([StatusCancelledDate] , GETDATE()) END WHERE (TaskID = @TaskID) |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2010-04-15 : 06:09:09
|
Formatted code:UPDATE kpitbl SET manager = @Manager, lead = @Lead, wrm = @WRM, prime = @PRIME, par = @PAR, pmo = @PMO, requestinglob = @RequestingLOB, lob = @LOB, propertyidstartloc = @PropertyIDStartLoc, tspanid = @TspanID, sdmsrec = @SDMSRec, requestid = @RequestID, propertyidfinishloc = @PropertyIDFinishLoc, DESCRIPTION = @Description, projecttype = @ProjectType, servername = @ServerName, servertype = @ServerType, dcoorstandalone = @DCOorSTANDALONE, techanalyst = @TechAnalyst, status = @Status, rag = CASE WHEN @Status = 'Completed' THEN 'C' WHEN @Status = 'Cancelled' THEN 'C' ELSE @RAG END, startdates = @StartDates, estimatedcompletiondate = @EstimatedCompletionDate, actualcompletiondate = @ActualCompletionDate, activity = @Activity, treeordomainimpacted = @TreeOrDomainImpacted, numofsites = @NumOfSites, numofusers = numofusers + @NumOfUsers, gbdatamoved = gbdatamoved + @GBdatamoved, gbdatadeleted = gbdatadeleted + @GBdatadeleted, numofsrvrsadded = @NumOfSrvrsAdded, eutengineeringconsult = @EUTEngineeringConsult, timespend = @TimeSpend, gbdatamovedplanned = @GBdatamovedPlanned, numofusersplanned = @NumOfUsersPlanned, complexity = @Complexity, ecm = @ECM, lastupdated = Getdate(), statuscompleteddate = CASE WHEN @Status = 'Completed' THEN Isnull([StatusCompletedDate], Getdate()) END, statuscancelleddate = CASE WHEN @Status = 'Cancelled' THEN Isnull([StatusCancelledDate], Getdate()) END WHERE ( taskid = @TaskID ) No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
|
|
|