I have this XML:
<Articles>
<Article>
<ArticleNo>31213496</Article_No>
<ArticleDes>PRESSNING</ArticleDes>
<Notes></Notes>
<EstimatedCycleTime>2.05714285714286</EstimatedCycleTime>
<Departments>
<Department isLinked="true" name="Finnveden Olofström" />
<Department isLinked="false" name="3333333333" />
<Department isLinked="true" name="company_hide" />
<Department isLinked="false" name="Department1" />
</Departments>
</Article>
</Articles>
I use this SQL to select Articles data:
declare
@articleNo nvarchar(25),
@articleDes nvarchar(255),
@notes nvarchar(max),
@cycleTime float
declare cls cursor scroll for
select a.value('Article_No[1]','nvarchar(25)'), a.value('ArticleDes[1]','nvarchar(255)'),a.value('Notes[1]','nvarchar(max)'),a.value('EstimatedCycleTime[1]','float')
from @xml.nodes('Articles/Article') as a(a)
open cls
fetch next from cls into @articleNo, @articleDes, @notes, @cycleTime
while @@FETCH_STATUS = 0
begin
select @articleNo, @articleDes, @notes, @cycleTime
fetch next from cls into @articleNo, @articleDes, @notes, @cycleTime
end
close cls
deallocate cls
How do I select departments names which have isLinked="true" for each Article?

{ }) on the editor toolbar to nicely format and syntax highlight it! That way, you can avoid all those messy ,<br/>etc. tags, too!!<ArticleNo>doesn't match the closing tag</Article_No>- probably just a typo, but be sure those tags match!