January 18, 2011 at 7:58 am
Let's say I have the following tables:
Task Table
-----------
Id [Guid]
Name [nvarchar(64)]
ParentId [Guid]
Time Entry Table
-----------------
Id [Guid]
EntryDate [DateTime]
HoursCharged [float]
TaskId [Guid]
1. I would like to load the entire hierarchy of a parent Id in a single call. I know this is possible, but I'm not sure how.
2. I would like to sum all hours charged for each task. Can I do this in #1's SQL string?
Best Regards,
Eric
January 18, 2011 at 9:29 pm
ezimmerman 33749 (1/18/2011)
Let's say I have the following tables:Task Table
-----------
Id [Guid]
Name [nvarchar(64)]
ParentId [Guid]
Time Entry Table
-----------------
Id [Guid]
EntryDate [DateTime]
HoursCharged [float]
TaskId [Guid]
1. I would like to load the entire hierarchy of a parent Id in a single call. I know this is possible, but I'm not sure how.
2. I would like to sum all hours charged for each task. Can I do this in #1's SQL string?
Best Regards,
Eric
Lookup "Recursive CTEs" in Books Online (the Help system that comes with SQL Server). That should do the trick for you.
If you provide some tables and data in the readily consumable format identified by the first link in my signature line below, we can give you a coded answer.
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 2 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply