Re: is this bad?

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance

From: djc (noone_at_nowhere.com)
Date: 11/02/04


Date: Tue, 2 Nov 2004 09:06:42 -0500

understood. Note that the link you provided is the same link I put in my
orginal post. Thats where I got the solution I'm using now. But after
someone told me that any DBA would not be very happy with it I decided to
post here to see if that was true.. and if so, why?

thanks for the reply though. I do appreciate it.

"Tibor Karaszi" <tibor_please.no.email_karaszi@hotmail.nomail.com> wrote in
message news:uPr0tLOwEHA.1300@TK2MSFTNGP14.phx.gbl...
> There's seldom a "right" or "wrong" way of doing something. With enough
information, you will be
> able to make an informed decision. This might be a good place to start:
> http://www.aspfaq.com/2501
>
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://www.solidqualitylearning.com/
>
>
> "djc" <noone@nowhere.com> wrote in message
news:OhTZy6NwEHA.1512@TK2MSFTNGP12.phx.gbl...
> > I got this solution from here: http://www.aspfaq.com/show.asp?id=2501
> > I was told the "Gods" of SQL are found here (not the link above, but
here
> > here) and could help. Anothers input in a dotnet forum said something to
the
> > effect the any DBA would be very unhappy with this.
> >
> > I am using a stored procedure to retrieve data for an asp.net datagrid
that
> > needs to be sortable and pageable. This means I need to pass in 2
variables,
> > what column to sort by and whether its ASC or DESC. Here is what I have
now
> > and it seems to work fine. Note I have JUST started to try to transition
> > from putting SQL directly in my code to using stored procedures so I
REALLY
> > don't know what I'm doing yet!
> >
> > CREATE PROCEDURE dbo.GetAllIssues
> > (
> > @SortBy VarChar(50), @Asc_Desc VarChar(8)
> > )
> > AS
> >
> > SELECT MainID, Title, ShortDesc, EstimatedDeliveryDate, Status
> > FROM tblMain
> > ORDER BY
> >
> > CASE @Asc_Desc
> > WHEN 'desc' THEN
> > CASE @SortBy
> > WHEN 'MainID' THEN MainID
> > END
> > END
> > Desc,
> >
> > CASE @Asc_Desc
> > WHEN 'desc' THEN
> > CASE @SortBy
> > WHEN 'Title' THEN Title
> > END
> > END
> > DESC,
> >
> > CASE @Asc_Desc
> > WHEN 'desc' THEN
> > CASE @SortBy
> > WHEN 'EstimatedDeliveryDate' THEN EstimatedDeliveryDate
> > END
> > END
> > DESC,
> >
> > CASE @Asc_Desc
> > WHEN 'desc' THEN
> > CASE @SortBy
> > WHEN 'Status' THEN Status
> > END
> > END
> > DESC,
> >
> > CASE @Asc_Desc
> > WHEN 'asc' THEN
> > CASE @SortBy
> > WHEN 'MainID' THEN MainID
> > END
> > END,
> >
> > CASE @Asc_Desc
> > WHEN 'asc' THEN
> > CASE @SortBy
> > WHEN 'Title' THEN Title
> > END
> > END,
> >
> > CASE @Asc_Desc
> > WHEN 'asc' THEN
> > CASE @SortBy
> > WHEN 'EstimatedDeliveryDate' THEN EstimatedDeliveryDate
> > END
> > END,
> >
> > CASE @Asc_Desc
> > WHEN 'asc' THEN
> > CASE @SortBy
> > WHEN 'Status' THEN Status
> > END
> > END
> > GO
> >
> > what do you think?
> >
> >
>
>