Site Sponsored By: SQLDSC - SQL Server Desired State Configuration
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.
Yup..just inherited a new database...they gave us their "Scripts" to build the database..unfortunatley..I compile the sprocs...columns not found...ambiguous column names...what have you...no error handling...but what rocket scientist came up with this?
CREATE PROCEDURE [dbo].[GetCaseCurrentOwner]( @Id INT)ASBEGIN SET NOCOUNT ON; SELECT ctl.AllocatedTo AS curOwnerId,appsec.FirstName + ' ' + appsec.LastName AS CurOwner FROM CaseTaskList ctl INNER JOIN CaseHeader ch On ctl.CaseId=ch.CaseId INNER JOIN AppSecurity appsec ON ctl.AllocatedTo=appsec.UserId INNER JOIN Status ON ch.StatusId=ctl.StatusId WHERE ctl.CaseId=@Id AND ctl.Id = (SELECT MAX(Id) FROM CaseTaskList Where CaseId=@Id) ENDGO