0
에 조인 된 테이블과 행에 열을 변환
I의 구조는 다음과 같습니다는 SQL
WordTemplatesByAssemblyPackage
[PackageId] [TemplateId]
WordTemplate
[TemplateId] [Name]
WordTemplatePlainDataMappings
[TemplateId] [UDF01SdtTag] [UDF02SdtTag] [UDF03SdtTag] ... [UDF20SdtTag]
WordTemplateTableDataMappings
[TemplateId] [TableContainerSdtTag] [Col01SdtTag] [Col02SdtTag] ... [Col10SdtTag]
내가 다음 쿼리를 변환하기 위해 열심히 노력했습니다 대신 열을 선택하는 I 행
로 변환 할을SELECT
t.Name,
pd.UDF01SdtTag,
pd.UDF02SdtTag,
pd.UDF03SdtTag,
tpd.TableContainerSdtTag,
tpd.Col01SdtTag,
tpd.Col02SdtTag,
tpd.Col03SdtTag
FROM
doc.WordTemplatesByAssemblyPackage AS p
INNER JOIN doc.WordTemplate AS t ON p.TemplateId = t.TemplateId AND p.TemplateId = t.TemplateId
LEFT JOIN doc.WordTemplatePlainDataMappings AS pd ON pd.TemplateId = t.TemplateId AND pd.TemplateId = t.TemplateId
LEFT JOIN doc.WordTemplateTableDataMappings AS tpd ON tpd.TemplateId = t.TemplateId AND tpd.TemplateId = t.TemplateId
WHERE
p.PackageId = 3
내가 unpiv과 노력했습니다하지만 난 얻을 모두가 마지막으로
42000 - [SQL Server]The column 'TemplateId' was specified multiple times for 'unpiv'.
42000 - [SQL Server]The multi-part identifier "p.TemplateId" could not be bound.
, 난 결과입니다
t.Name Field Value
Template 1 Field 1 Value
Template 1 Field 2 Value
Template 1 Table 1 - Field 1 Value
Template 2 Field 1 Value
Template 2 Table 1 Field 1 Value