Advertisement

07.14.2007 at 09:13PM PDT, ID: 22696919
[x]
Attachment Details

MS-SQL 2000 Basic T-SQL/Stored Proceduer Help

Asked by Sentis in MS SQL DTS, MS SQL Server, SQL Query Syntax

Tags: subtract, 1, 2000, ms, sql

Hi, I need a T-SQL Stored Proceduer defined for MS-SQL 2000
The purpose of the Stored Proceduer will be to subtract 1 (ONE) from a stored integer in a field.

Here's the complete scenario:
I have a table with 5 columns, one of the columns holds integer values. I want to pass two variables to the proceduer, namely @orderno and @email based on which the SELECT statement will fetch the right record.
From this record the Integer number field will have 1 subtracted from it and the record in the database updated.

In other words: using for example the ordernumber: 12345 and email support@example.com the integer field "slots" is accessed in the SELECT statement SELECT slots from tblUser where tblUser.orderno = @orderno AND tblUser.email = @email

The stored proceduer should run this select statement and then subtract 1 (-1) from the slots field and update the record.

Also, in an IF statement or likewise, the stored proceduer should check that the number in the slots field is != 0 if it is, then the subtraction should not take place.

The stored proceduer should do this everytime it's executed.

Since thios is SQL 2000 and not 2005 hence TRY/CATCH exception handling is not available either. Any suggestions for appropriate error handling would be appreciated.

Am using ASP.NET (VB.NET) for FrontEnd if that's helpful.Start Free Trial
[+][-]07.14.2007 at 09:37PM PDT, ID: 19489119

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: MS SQL DTS, MS SQL Server, SQL Query Syntax
Tags: subtract, 1, 2000, ms, sql
Sign Up Now!
Solution Provided By: derekkromm
Participating Experts: 2
Solution Grade: A
 
 
[+][-]07.14.2007 at 09:38PM PDT, ID: 19489122

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.14.2007 at 09:44PM PDT, ID: 19489128

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.14.2007 at 09:55PM PDT, ID: 19489145

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.14.2007 at 10:06PM PDT, ID: 19489158

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32