I have a tabled defined as:
CREATE TABLE [dbo].[DocumentData](
[doc_id] [int] NOT NULL,
[ddt_FieldName] [nvarchar](20) NULL,
[ddt_FieldValue] [nvarchar](100) NULL,
[ddt_Changed] [bit] NULL,
[ddt_ChangedUserId] [int] NULL,
[ddt_ChangedDateTime] [datetime] NULL,
[id] [int] IDENTITY(1,1) NOT NULL
) ON [PRIMARY]
It contains data collected from a document - identified by doc_id.
For each document there are many rows where each row is a field name and a field value.
If i know that my document has ddt_FieldNames of A, B, C and D how would i write an sql statement to produce all the data in columns for document with doc_id 6?
I am looking for output like:
doc_id A B C D
6 10 66 12 13
where A, B, C, and D have respective ddt_FieldValues of 10, 66, 12 , 13