Advertisement

12.27.2007 at 10:03PM PST, ID: 23046604
[x]
Attachment Details

Return Column Names In Results - SQL Server 2005

Asked by JackW9653 in SQL Server 2005

Tags: column, return, sql, names

Hello Experts,

Here is the query I am using to return specific Dx codes and their associated descriptions and locations:
SELECT DISTINCT LookupDiags.Code, LookupDiags.Description, LookupDiags.Location, tblPatientData.Payer1
FROM tblPatientData
INNER JOIN LookupDiags ON
ISNULL(tblPatientData.DX1, N'000') = LookupDiags.Code OR
tblPatientData.DX1 = LookupDiags.Code OR
tblPatientData.DX2 = LookupDiags.Code OR
tblPatientData.DX3 = LookupDiags.Code OR
tblPatientData.DX4 = LookupDiags.Code
WHERE ((tblPatientData.CaseNumber)=10208001)

This would return something like:
Code             Description                                                Location
727.81          Contracture of Tendon                              Foot/Ankle

What I need returned is something like the following:

DX       Code                            Description                          Location
DX1      727.81              Contracture of Tendon                  Foot/Ankle

Where DX represents the field name where the data was returned from. Obviously there can be up to 4 codes for each Case Number.

Thanks in advance for your help.

JackW9653        Start Free Trial
[+][-]12.27.2007 at 10:08PM PST, ID: 20539988

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: SQL Server 2005
Tags: column, return, sql, names
Sign Up Now!
Solution Provided By: asvforce
Participating Experts: 1
Solution Grade: A
 
 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628