|
Posted by David Portas on 03/24/06 22:48
Herb Caudill wrote:
> >>> incompetent people ... ignorance ... amatuer or a hillbilly ...
> dangerous moron ... clean up their crap ... This is how Ghod punishes
> you for your bad code ... Satan ... etc. <<<
>
> My goodness, Celko. Where is this anger coming from? A little out of
> proportion to the subject matter, if you ask me. I'd genuinely like to
> learn from you, since you obviously know more than I do, but the
> bile-to-wisdom ratio of your posts makes it tempting to just ignore you.
> That would be a shame, wouldn't it?
>
> Here's a simple real-life situation; let's see if we can work together,
> keep our blood pressure down, and come up with a solution that is both
> practical and theoretically pure.
>
> 1. You have a SQL table containing website content.
> 2. 25 different parts of the website display 25 different subsets of
> this content.
> 3. The content on every page should be sorted in exactly the same way.
> The sorting logic is relatively complex and subject to change.
>
> Here's how I might have handled this on SQL Server 2000:
> 1. Create a base view that incorporates the sorting logic: Select top
> 100 percent ... order by ... (the sound you hear is Celko calling down
> divine wrath upon me and my children and my children's children)
> 2. Create 25 child views to return subsets of the base view.
>
> Of course, now that I've been punished by the almighty for my crimes
> against humanity, this is no longer an option. Some suggest moving the
> sorting logic to the client - which would require the same exact "order
> by" clause 25 places in my .NET code. This is unsatisfactory because I
> have to maintain the same logic in 25 different places. Can we do
> better?
>
Use a stored proc. I don't know why that would be a problem for you.
Best practice is to use procs for ALL data access. Don't ask why procs
can sort and views can't. I've no intention of repeating myself again
:-).
--
David Portas, SQL Server MVP
Whenever possible please post enough code to reproduce your problem.
Including CREATE TABLE and INSERT statements usually helps.
State what version of SQL Server you are using and specify the content
of any error messages.
SQL Server Books Online:
http://msdn2.microsoft.com/library/ms130214(en-US,SQL.90).aspx
--
Navigation:
[Reply to this message]
|