Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Complex SP - need some ideas
Message
From
29/08/2008 11:11:18
Mike Yearwood
Toronto, Ontario, Canada
 
General information
Forum:
Microsoft SQL Server
Category:
Stored procedures, Triggers, UDFs
Environment versions
SQL Server:
SQL Server 2005
Miscellaneous
Thread ID:
01343077
Message ID:
01343137
Views:
19
>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.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform