Ask a Question related to ASP Database, Design and Development.
-
Ajak #1
SQL string question
Hi all,
I have a situation here. I have a table (Options) which has the following
single record {field}={value}:-
Quota=50 (smalllint)
CarryFwd=1 (bit - can be 0 or 1)
CarryFwdMax=20 (smallint)
And I have a table (Users) which has the concerned field called AvailCredit
as one of its fields.
I would like to update the field AvailCredit based on the values in Options
table as follows:-
If Options.CarryFwd value is 0 then
Users.AvailCredit will be changed to Options.Quota regardless of what it's
initial value is.
If Options.CarryFwd value is 1 then
Users.AvailCredit will be changed to Options.Quota+(Users.AvailCredit or
Options.CarryFwdMax, whichever is lower)
How do I write the SQL string as a single execution without having to read
and update each users record in the application's for...next loop? Is that
possible?
I'm using MS SQL for the database.
Thanks!
Ajak Guest
-
Another String Manipulation Question
Let's say I have a variable like this: 12345432112347890 The characters in the variable will always be different, but my goal will always be... -
string question: how to append x zeros to get fixed lenght string?
"Bob Barrows" <reb_01501@yahoo.com> wrote in message news:uuhVv4mcDHA.656@tk2msftngp13.phx.gbl... newstring = Right("0000000" & i,8) ;-p -
String question: Returning portion of string with words surrounding highlighted search term?
I'm looking to find or create an ASP script that will take a string, examine it for a search term, and if it finds the search term in the string,... -
STRING FORMATTING QUESTION
My question is regarding strings in php. I have this form in which the user fills in a description. The problem is that if the user uses any... -
string question
i am a perl novice, and i have a really simple question. what is the easiest way to tell if a string begins with "Re: " (without the quotes)? ... -
Bob Barrows #2
Re: SQL string question
Ajak wrote:
This is off the top of my head so it is not tested.> Hi all,
>
> I have a situation here. I have a table (Options) which has the
> following single record {field}={value}:-
>
> Quota=50 (smalllint)
> CarryFwd=1 (bit - can be 0 or 1)
> CarryFwdMax=20 (smallint)
>
> And I have a table (Users) which has the concerned field called
> AvailCredit as one of its fields.
>
> I would like to update the field AvailCredit based on the values in
> Options table as follows:-
>
> If Options.CarryFwd value is 0 then
> Users.AvailCredit will be changed to Options.Quota regardless of what
> it's initial value is.
>
> If Options.CarryFwd value is 1 then
> Users.AvailCredit will be changed to Options.Quota+(Users.AvailCredit
> or Options.CarryFwdMax, whichever is lower)
>
UPDATE u
SET AvailCredit =
CASE CarryFwd WHEN 0 THEN
Quota
ELSE
CASE WHEN CarryFwdMax > Quota + AvailCredit THEN
Quota + AvailCredit
ELSE
CarryFwdMax
END
END
FROM Users u CROSS JOIN Options o
HTH,
Bob Barrows
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
Bob Barrows Guest



Reply With Quote

