Showing posts with label request. Show all posts
Showing posts with label request. Show all posts

Tuesday, March 20, 2012

Case Expression within a Stored Proc

Is it possible? I have a request to create a stored proc that will
dynamically add a range to a WHERE clause based on a numeric value of a
comment type. If the incoming comment type request is say 10, the
where clause needs to be set to IN(10,11,12,13,14,15,16,17,18,19)OR if
a 20 is passed in the clause would read IN(20,21....)
So I was thinking that a CASE expression within the proc would be the
best way to go, but have had no luck in finding an example or any other
related information regarding CASE exp in a proc.
TIA
BillOn 8 Sep 2004 06:44:18 -0700, Bill Willyerd wrote:

>Is it possible? I have a request to create a stored proc that will
>dynamically add a range to a WHERE clause based on a numeric value of a
>comment type. If the incoming comment type request is say 10, the
>where clause needs to be set to IN(10,11,12,13,14,15,16,17,18,19)OR if
>a 20 is passed in the clause would read IN(20,21....)
>So I was thinking that a CASE expression within the proc would be the
>best way to go, but have had no luck in finding an example or any other
>related information regarding CASE exp in a proc.
>TIA
>Bill

Hi Bill,

In this case (no pun intended), I'd simply write it like this:

WHERE MyColumn BETWEEN @.parameter AND @.parameter + 9

Best, Hugo
--

(Remove _NO_ and _SPAM_ to get my e-mail address)|||On 8 Sep 2004 08:17:57 -0700, Bill Willyerd wrote:

>Sorry I didn't add that if a request for specfic comment type comes in
>like 22 we only return the type 22's.
>I do like the BETWEEN stmt though I haven't seen that before, I will
>remember that one.
>Thx, Bill

Hi Bill,

Is the request for "a specific comment type" passed in through a seperate
parameter? And the other parameter is used to get a range of comment
types?

CREATE PROC MyProc @.Specific int,
@.RangeStart int
AS
IF (@.Specific IS NULL AND @.RangeStart IS NULL)
OR (@.Specific IS NOT NULL AND @.RangeStart IS NOT NULL)
RAISERROR ('Supply exactly one of the two parameters', 16, 1)
ELSE
IF @.Specific IS NOT NULL
SELECT Column List
FROM YourTable
WHERE MyColumn = @.Specific
ELSE
SELECT Column List
FROM YourTable
WHERE MyColumn BETWEE @.RangeStart AND @.RangeStart + 9
go
(untested)

Best, Hugo
--

(Remove _NO_ and _SPAM_ to get my e-mail address)|||On 8 Sep 2004 16:28:26 -0700, Bill Willyerd wrote:

>At present it comes as a single request.
(snip)

Hi Bill,

How do you know if the request is for a specific comment type or for a
range? Surely, there has to be some way to distinguish a request for
comment type '20' (meaning just 20) from a request for comment type '20'
(meaning all values 20 through 29).

Maybe this is a good time to explain what information should be included
in newsgroup postings to maximise the chance to get a useful reply:

* Table structure, posted as DDL (CREATE TABLE statements, omitting
irrelevant columns but including all constraints);
* Sample data, posted as INSERT statements (and please verify that the
CREATE TABLE and INSERT statements you post work properly in an empty test
database!);
* Expected output, based on sample data;
* The SQL code you already got (if any), plus the results these give you
and the reason why that is wrong. If you get an error message, copy and
paste the full message;
* A short, concise description of the business problem you're trying to
solve.

Check out these sites as well:
http://www.aspfaq.com/etiquette.asp?id=5006
http://vyaskn.tripod.com/code.htm#inserts

Best, Hugo
--

(Remove _NO_ and _SPAM_ to get my e-mail address)

Thursday, February 16, 2012

Capacity Planning

We are going to install a call centre application.
According to end user, there will be around 500 request
has to be inputted into the system.
We will use SQL Server 2000 as the DB. We would like to
know what factors we have to consider - Like recovery
model, database maintenance plan, fill factors ? Is it
necessary for us to archive some old data to an archive
datbase ?
Thanks"Peter" <anonymous@.discussions.microsoft.com> wrote in message
news:1cb701c4b569$d40000a0$a401280a@.phx.gbl...
> We are going to install a call centre application.
> According to end user, there will be around 500 request
> has to be inputted into the system.
>
500 requests over what time period?
> We will use SQL Server 2000 as the DB. We would like to
> know what factors we have to consider - Like recovery
> model, database maintenance plan, fill factors ? Is it
> necessary for us to archive some old data to an archive
> datbase ?
>
Those are really business decisions.
i.e. if you need to run 24x7 vs 9-5x5, your decisions will be different.
If you can do with downtime, you may go with a different decisions on
architecture.
As for archiving, again, that's a business decision. Do you want to archive
data or not?
> Thanks|||Dear Greg,
It should be 500 requests between 9:00am to 5:00pm from
Monday to Friday.
We will make full database backup daily. What is the
difference between full database backup and archive then ?
Thanks|||"Peter" <anonymous@.discussions.microsoft.com> wrote in message
news:0fba01c4b574$0e2f4830$a501280a@.phx.gbl...
> Dear Greg,
> It should be 500 requests between 9:00am to 5:00pm from
> Monday to Friday.
500 a day? That's about one a minute. You can run this thing on a desktop
machine.
> We will make full database backup daily. What is the
> difference between full database backup and archive then ?
Generally a backup is for disaster recovery. An archive is for storing data
for later analysis or for other reasons.
For example, I keep backups of only a few days (my databases generally have
enough churn that in a few days the bulk of the data has changed anyway.)
But there's certain data I archive to tape (in a different schema etc) that
I may keep for much longer.
Now, as for once a day backups, that may or may not work. Your database
sounds like it will probably be fairly small to start, so recovery time will
be about the same as backup. i.e. if it takes 10 minutes to backup, it'll
take about 10 minutes to restore. Plus any time to fix up minor issues.
However, let's say you start a backup at 5:01 PM.
What happens if your DB crashes at 5:00 PM. Can you afford to lose a day's
worth of data?
> Thanks
>