Просто добавьте ORDER BY
в ваше утверждение, которое сгенерировало столбцы:
SET @cols = STUFF((SELECT ',' + QUOTENAME((tgl))
FROM tblabsen
WHERE priode = @priode
GROUP BY tgl
ORDER BY tgl ASC
FOR XML PATH(''), TYPE).value('.', 'NVARCHAR(MAX)'),1,1,'');
Я также предлагаю параметризировать ваше динамическое утверждение. Измените where priode = '''+@priode+'''
на
WHERE priode = @priode
, а затем измените свой sp_executesql
на:
EXEC sp_executesql @query, N'@priode nvarchar(6)', @priode = @priode;
Редактируйте, я только что заметил, почему @cols
и @query
параметр здесь? Удалите их из списка параметров и DECLARE
в SP.
This MSDN page has all the information you might want to know about resource URIs in WPF (often called pack URIs). You're going to want to use relative URIs more often probably, so see Table 4, which should be of particular use.
If you want a briefer overview of resource (pack) URIs, see this blog post. It shows that syntax is indeed relatively simple:
pack://application:,,,/ResourceFile.xaml
pack://application:,,,/ReferencedAssembly;component/ResourceFile.xaml
However, there are a few quirks to work out (in my experience), so often finding the correct resource URI requires a bit of experimentation.