Thomas stand ja kürzlich vor dem Problem, eine CTE hierarchisch korrekt ausgeben zu wollen, was ihn zu Niels Berglund führte (Sorting Hierarchical CTE's).
Allerdings blieb ein Problem: Die Daten sind nun zwar hierarchisch sortiert - nicht jedoch alphabetisch innerhalb der Hierarchie.
Heute stand ich schließlich vor dem gleichen Problem - und ich glaube, ich habe eine Lösung gefunden ;-)
Ausgehend von einer Tabelle Kategorien, welche die Felder Name (nvarchar), ID (uniqueidentifier) und Parent (uniqueidentifier) besitzt, sollen also die Kategorien hierarchisch und alphabetisch dargestellt werden:
Korrekt wäre also z.B.:
| Name |
ID |
Parent |
| Rohre und Formteile |
C55C8856-6205-4F76-A15A-6FCD4A68A831 |
00000000-0000-0000-0000-000000000000 |
| Geschweißte Rohre und Formteile |
9EEE0951-4E63-4494-BB18-88BCC1D4A3E5 |
C55C8856-6205-4F76-A15A-6FCD4A68A831 |
| Rohrbögen geschweißt |
8A137449-6108-47D2-8ED0-AE0EA4176EB2 |
9EEE0951-4E63-4494-BB18-88BCC1D4A3E5 |
| Rohre geschweißt |
085A0AA3-AB9D-4DD1-9739-77040E627445 |
9EEE0951-4E63-4494-BB18-88BCC1D4A3E5 |
Erhalten habe ich mit Niels' Lösung jedoch nur:
| Name |
ID |
Parent |
| Rohre und Formteile |
C55C8856-6205-4F76-A15A-6FCD4A68A831 |
00000000-0000-0000-0000-000000000000 |
| Geschweißte Rohre und Formteile |
9EEE0951-4E63-4494-BB18-88BCC1D4A3E5 |
C55C8856-6205-4F76-A15A-6FCD4A68A831 |
| Rohre geschweißt |
085A0AA3-AB9D-4DD1-9739-77040E627445 |
9EEE0951-4E63-4494-BB18-88BCC1D4A3E5 |
| Rohrbögen geschweißt |
8A137449-6108-47D2-8ED0-AE0EA4176EB2 |
9EEE0951-4E63-4494-BB18-88BCC1D4A3E5 |
Nach einigem Experimentieren mit Views u.ä. bin ich auf folgende Lösung gekommen:
WITH CTE([Name], ID, ordercol, Parent)
AS
(
SELECT [Name], ID, cast([Name] as varbinary(100)) ordercol, Parent
FROM ProductCategory
WHERE Parent= '{00000000-0000-0000-0000-000000000000}'
UNION ALL
SELECT ProductCategory.[Name],
ProductCategory.ID,
cast(ordercol + CAST(ProductCategory.[Name] AS BINARY(4)) as varbinary(100)) ordercol,
ProductCategory.Parent
FROM ProductCategory INNER JOIN
CTE ON ProductCategory.Parent =
CTE.ID
)
SELECT [Name], ID, Parent
FROM CTE
ORDER BY ordercol, [Name]
Damit erhielt ich o.g. gewünschtes hierarchisch und alphabetisch korrekt sortiertes Resultat. Außerdem funktioniert jetzt sogar die Änderung von ORDER BY auf [Name] DESC.
Be the first to rate this post
- Currently 0/5 Stars.
- 1
- 2
- 3
- 4
- 5
SqlPrompt (aktuell noch Beta) ist ein Windows-Tool, das sich im Systray einnistet und von dort aus SQL-Intellisense für folgende Editoren bietet:
- Query Analyzer (2000)
- Enterprise Manager (2000)
- Sql Server Management Studio (2005)
- Visual Studio .NET 2003
- Visual Studio 2005
- Ultra Edit
- EditPlus 2
SqlPrompt im Query Analyzer in Action:

Be the first to rate this post
- Currently 0/5 Stars.
- 1
- 2
- 3
- 4
- 5
Die aktualisierte Version der SQL Server 2005 Dokumentation liegt zum Download (en/de) bereit.
Be the first to rate this post
- Currently 0/5 Stars.
- 1
- 2
- 3
- 4
- 5
Bereits wenige Monate nach dem Erscheinen von SQL Server 2005 ist nun das Service Pack 1 zum Download verfügbar.
Um die Express Editions zu aktualisieren, müssen die aktualisierten Versionen mit SP1 heruntergeladen und installiert werden.
Hierbei gibt es jetzt außerdem zusätzlich zum Download mit normalem Funktionsumfang auch eine Version mit Reporting Services und Volltextsuche zum Download.
Be the first to rate this post
- Currently 0/5 Stars.
- 1
- 2
- 3
- 4
- 5
If you've finished reading about the breaking changes in .NET Framework 2005, you may be interested in what's new in Visual Studio 2005 and SQL Server 2005.
So, here's the bunch of information on what's new:
Be the first to rate this post
- Currently 0/5 Stars.
- 1
- 2
- 3
- 4
- 5


Now it's time to develop some really cool applications ;-)
Be the first to rate this post
- Currently 0/5 Stars.
- 1
- 2
- 3
- 4
- 5
Get the hottest information on SQL Server 2005, Visual Studio 2005 and BizTalk Server 2006 straight from the product teams:

Be the first to rate this post
- Currently 0/5 Stars.
- 1
- 2
- 3
- 4
- 5
Visual Studio 2005 and SQL Server 2005 developer edition are available at MSDN Subscriber Downloads now. Pretty cool ;-)
Be the first to rate this post
- Currently 0/5 Stars.
- 1
- 2
- 3
- 4
- 5
Today I tried to create a SQL Server 2005 Diagram using Microsoft Office Visio 2003. But when calling the Reverse Engineering command using the SQL Server / SQL Native Client for SQL Server 2005 I got the following error message:

After googling a for a while I read about a Visio 2005 for Enterprise Architects beta (when participating in the VS 2005 beta program), but I also read some posts that it expired already.
But I found another solution that works fine with Visio 2003:
Instead of using the SQL Server / SQL Native Client I'm using the Generic OLE DB Provider:

After clicking "Next", I'm selecting the SQL Native Client which I'm configuring as I used to do it before:

Then I click the "Next" button

After clicking "OK" I can select the desired database objects being displayed in the diagram - et voila:
Be the first to rate this post
- Currently 0/5 Stars.
- 1
- 2
- 3
- 4
- 5