-- This will take time to load up (almost FOREVER?) :(
SELECT *
FROM
(SELECT
[TestId] = 999
-- Attribute(s):
,col.value('../@JeepNumber', 'varchar(10)') as JeepNumber
,col.value('../@AccountPeriod', 'varchar(10)') as AccountPeriod
,col.value('../@TotalNonConformityDeviation', 'decimal(18,2)') as TotalNonConformityDeviation
,col.value('../@TotalWorkhours', 'decimal(18,2)') as TotalWorkhours
-- Normal column(s):
,col.value('data(PersonEmployeeId[1])', 'int') as PersonEmployeeId
,col.value('data(RankCode[1])', 'varchar(10)') as RankCode
,col.value('data(PeriodDate[1])', 'varchar(10)') as PeriodDate
,col.value('data(Comments[1])', 'varchar(max)') as Comments
,col.value('data(RestHourApplicableIn24hHourPeriod[1])', 'decimal(18,2)') as RestHourApplicableIn24hHourPeriod
,col.value('data(RestHourApplicableIn7DayPeriod[1])', 'decimal(18,2)') as RestHourApplicableIn7DayPeriod
,col.value('data(RestHourIntervalCode[1])', 'varchar(5)') as RestHourIntervalCode
,col.value('data(PeriodValue[1])', 'varchar(1)') as PeriodValue
FROM
@XmlAltered.nodes('/RestHours/RestHour') tbl(col)) x
-- Resolution (3 seconds to load):
-- Extract Attribute(s):
DECLARE
@JeepNumber varchar(10)
,@AccountPeriod varchar(10)
,@TotalNonConformityDeviation decimal(18,2)
,@TotalWorkhours decimal(18,2)
SELECT
@JeepNumber = x.JeepNumber
,@AccountPeriod = x.AccountPeriod
,@TotalNonConformityDeviation = x.TotalNonConformityDeviation
,@TotalWorkhours = x.TotalWorkhours
FROM
(SELECT TOP 1
-- Attribute(s):
col.value('../@JeepNumber', 'varchar(10)') as JeepNumber
,col.value('../@AccountPeriod', 'varchar(10)') as AccountPeriod
,col.value('../@TotalNonConformityDeviation', 'decimal(18,2)') as TotalNonConformityDeviation
,col.value('../@TotalWorkhours', 'decimal(18,2)') as TotalWorkhours
FROM
@XmlAltered.nodes('/RestHours/RestHour') tbl(col)) x
-- Combined attributes extacted above
SELECT
[JeepNumber] = @JeepNumber
,[AccountPeriod] = @AccountPeriod
,[TotalNonConformityDeviation] = @TotalNonConformityDeviation
,[TotalWorkhours] = @TotalWorkhours
,x.*
FROM
(SELECT
[TestId] = 999
,col.value('data(PersonEmployeeId[1])', 'int') as PersonEmployeeId
,col.value('data(RankCode[1])', 'varchar(10)') as RankCode
,col.value('data(PeriodDate[1])', 'varchar(10)') as PeriodDate
,col.value('data(Comments[1])', 'varchar(max)') as Comments
,col.value('data(RestHourApplicableIn24hHourPeriod[1])', 'decimal(18,2)') as RestHourApplicableIn24hHourPeriod
,col.value('data(RestHourApplicableIn7DayPeriod[1])', 'decimal(18,2)') as RestHourApplicableIn7DayPeriod
,col.value('data(RestHourIntervalCode[1])', 'varchar(5)') as RestHourIntervalCode
,col.value('data(PeriodValue[1])', 'varchar(1)') as PeriodValue
FROM
@XmlAltered.nodes('/RestHours/RestHour') tbl(col)) x
Comments
Post a Comment