Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Complex SP - need some ideas
Message
De
29/08/2008 11:11:18
Mike Yearwood
Toronto, Ontario, Canada
 
 
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Stored procedures, Triggers, UDFs
Versions des environnements
SQL Server:
SQL Server 2005
Divers
Thread ID:
01343077
Message ID:
01343137
Vues:
20
>Hi everybody,
>
>I have a page with Search User Control. This User Control allows to search by Name, by Description and by Date. It also has Operator, which may be set to Equal, Less than or Greater than. In addition is has a DropDown option of All (Events & Programs), Events Only, Programs Only.
>
>Also when I start my page I use some extra where condition, which is not used once Search was used.
>
>Right now everything is coded directly using string contatenation.

You can build Parameterized Ad-Hoc SQL via concatenation. It is perfectly acceptable.

>
>I'm thinking of moving this logic into SP with these parameters
>
>@FirstTime bit
>@EName
>@EDescription
>@StartTime
>@EndTime
>@Operator
>@IncludeType
>
>I'm guessing that I have to use 3 different paths IF ELSE IF depedning on operator.

Even in an SP you can build Parameterized Ad-Hoc SQL via concatenation. Just be sure to parameterize the values in the SQL. It is not enough to simply accept parameters into the SP.

>
>My question here is this - does it sound reasonable to create 2 table valued functions - one for Events and one for Programs so it would be easier to use them depending on Include Type in this SP?
>
>Or just one SP without functions may be a better choice?
>
>I'm thinking that functions is the way to go, but need some input from experts.
>
>Thanks in advance.

Sounds like a single Query with UNION and where clauses to include / exclude events and/or programs.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform