Hi all. I am a first time poster and a relative neophyte when it come to SQL stored procedures.
I have an existing SP that I am trying to modify. The existing SP gives me all of the latest weights on a group of patients in our hospital. I am trying to add the patient's heights as well. The values are stored in metric so I have to convert them to imperial values to display on my report. I am getting errors that I do not know what to do with. Any help is appreciated.
With the above code, I get the following error
Server: Msg 170, Level 15, State 1, Procedure FH_2Weights_R_PR, Line 92
Line 92: Incorrect syntax near '='.
If I try and use @Text, I get an error that I need to declare @Text. I added
between the AS and SELECT statements but then received the error
Server: Msg 107, Level 16, State 3, Procedure FH_2Weights_R_PR, Line 91
The column prefix 'CV3PhysicalNoteDeclaration' does not match with a table name or alias name used in the query.
Server: Msg 107, Level 16, State 1, Procedure FH_2Weights_R_PR, Line 92
The column prefix 'CV3PhysicalNoteDeclaration' does not match with a table name or alias name used in the query.
Server: Msg 107, Level 16, State 1, Procedure FH_2Weights_R_PR, Line 94
The column prefix 'CV3PhysicalNoteDeclaration' does not match with a table name or alias name used in the query.
I know that this is lengthy so my appologies for that. Any help is appreciated.
Thank you...
Mitch
I have an existing SP that I am trying to modify. The existing SP gives me all of the latest weights on a group of patients in our hospital. I am trying to add the patient's heights as well. The values are stored in metric so I have to convert them to imperial values to display on my report. I am getting errors that I do not know what to do with. Any help is appreciated.
Code:
SELECT
CV3ClientVisit.ChartGUID,
CV3ClientVisit.ClientGUID,
CV3ClientVisit.ClientDisplayName,
CV3ClientVisit.CurrentLocation,
CV3ClientVisit.ProviderDisplayName,
CV3ClientVisit.InternalVisitStatus,
CV3Client.BirthYearNum,
CV3Client.BirthMonthNum,
CV3Client.BirthDayNum,
CV3Client.GenderCode,
CV3Client.IDCode,
CV3Client.IsMaterialized,
CV3VisitListJoin_R.ObjectGUID,
CV3PhysicalNoteDeclaration.TouchedWhen,
CV3PhysicalNoteDeclaration.Text,
CV3PhysicalNoteDeclaration.TypeCode,
CV3Order.GUID,
CV3Order.Name,
CV3Order.RequestedDTM,
CV3Order.RequestedTime,
CV3Order.FrequencyCode,
CV3Order.SummaryLine
FROM
CV3ClientVisit
INNER JOIN CV3VisitListJoin_R
ON ( CV3VisitListJoin_R.ObjectGUID = CV3ClientVisit.GUID
AND CV3VisitListJoin_R.JobID = @JobID )
INNER JOIN CV3Client
ON ( CV3ClientVisit.ClientGUID = CV3Client.GUID )
LEFT OUTER JOIN CV3PhysicalNoteDeclaration ON
CV3ClientVisit.GUID = CV3PhysicalNoteDeclaration.ClientVisitGUID AND
CV3PhysicalNoteDeclaration.TypeCode = 'WEIGHT'
LEFT OUTER JOIN CV3Order ON
CV3ClientVisit.GUID = CV3Order.ClientVisitGUID AND
CV3ClientVisit.ClientGUID = CV3Order.ClientGUID AND
CV3ClientVisit.ChartGUID = CV3Order.ChartGUID AND
(Name = 'Weigh patient daily' OR
Name = 'Weigh patient daily: dialysis' OR
Name = 'Weigh patient daily: TPN' OR
Name = 'Weigh patient weekly: tube feeding' OR
Name = 'Weigh patient daily: CHF' OR
Name = 'Weigh patient')
AND
CV3Order.TouchedWhen = ( Select max(TouchedWhen)
from CV3Order
where
CV3ClientVisit.GUID = CV3Order.ClientVisitGUID AND
CV3ClientVisit.ClientGUID = CV3Order.ClientGUID AND
CV3ClientVisit.ChartGUID = CV3Order.ChartGUID AND
(Name = 'Weigh patient daily' OR
Name = 'Weigh patient daily: dialysis' OR
Name = 'Weigh patient daily: TPN' OR
Name = 'Weigh patient weekly: tube feeding' OR
Name = 'Weigh patient daily: CHF' OR
Name = 'Weigh patient')
AND CV3Order.Status = 'Active' )
IF CV3PhysicalNoteDeclaration.TypeCode = 'WEIGHT'
set Text = Cast (Round((Cast(CV3PhysicalNoteDeclaration.Text as Float)/1000 * 2.2046244201837774916665196917053),2) as VarChar (10)) + ' LB'
Else
set Text = Cast (Round((Cast(CV3PhysicalNoteDeclaration.Text as Float) * 0.3937),2) as VarChar (10)) + ' IN'
With the above code, I get the following error
Server: Msg 170, Level 15, State 1, Procedure FH_2Weights_R_PR, Line 92
Line 92: Incorrect syntax near '='.
If I try and use @Text, I get an error that I need to declare @Text. I added
Code:
DECLARE @TEXT Varchar(10)
Server: Msg 107, Level 16, State 3, Procedure FH_2Weights_R_PR, Line 91
The column prefix 'CV3PhysicalNoteDeclaration' does not match with a table name or alias name used in the query.
Server: Msg 107, Level 16, State 1, Procedure FH_2Weights_R_PR, Line 92
The column prefix 'CV3PhysicalNoteDeclaration' does not match with a table name or alias name used in the query.
Server: Msg 107, Level 16, State 1, Procedure FH_2Weights_R_PR, Line 94
The column prefix 'CV3PhysicalNoteDeclaration' does not match with a table name or alias name used in the query.
I know that this is lengthy so my appologies for that. Any help is appreciated.
Thank you...
Mitch