473,327 Members | 1,976 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,327 software developers and data experts.

Stored Procedure - Auto rotate staff with where clause.

Hai all,

I have problem here. Im using VWD with C#. Database Sql Server 2005. I have done auto rotation for staffname where autorotation = 1.

It was no problem until I add a new user with autorotation = 0. Where in adding new ticket form the staffname which is autorotate will appear in the label. But here it only show the new user that I add. It didn't rotate where actually it should not show the staffname if autorotation = 0.

here is the code:

Expand|Select|Wrap|Line Numbers
  1. CREATE PROCEDURE GetRotation
  2.  AS
  3.  
  4. declare @counter  int
  5.  
  6.  
  7. select @counter = count (*)   from staff where staffid >
  8. (
  9.                 select top 1 st.staffid from ticket tc
  10.                 inner join staff st on st.staffname = tc.ticowner
  11.        where st.autorotation = 1
  12.        order by ticid desc
  13. )
  14.  
  15. if @counter <> 0
  16. begin
  17.                 select top 1 staffname from staff where staffid >
  18.                 (
  19.                                 select top 1 st.staffid from ticket tc
  20.                                 inner join staff st on st.staffname = tc.ticowner
  21.              where st.autorotation = 1
  22.                                 order by ticid desc
  23.                 )
  24.  
  25. end
  26.  
  27. else
  28. begin
  29.                 select top 1 staffname from staff where autorotation = 1
  30.                 order by staffid asc
  31. end
  32. GO
Can anyone tell me where is the problem in the sp? Thanks in advance.

-Meshack
Nov 4 '08 #1
0 879

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Eric Herber | last post by:
I've a question regarding DB2 SQL Stored Procedures (DB2 V8.1.4 on Suse Linux). It seems not to be possible to use the 'where current of <cursor>' syntax in conjunction with dynamically prepared...
8
by: Thomasb | last post by:
With a background in MS SQL Server programming I'm used to temporary tables. Have just started to work with DB2 ver 7 on z/OS and stumbled into the concept of GLOBAL TEMPORARY TABLE. I have...
5
by: Timppa | last post by:
Hi, Could anyone help me with my problem ? Environment: Access 2000 and Sql Server 2000. I have a stored procedure as follows: DROP table1 SELECT alias1.field1,alias2.field2,table2.field6...
2
by: Dino L. | last post by:
How can I run stored procedure (MSSQL) ?
0
by: Amber | last post by:
Stored procedures are faster and more efficient than in-line SQL statements. In this article we will look at two SQL Server stored procedures; one using an input parameter and one not, and see how...
1
by: deepdata | last post by:
Hi, I am trying to fetch data from db2 (express version) database by calling stored procedure. I have tried to use both cursor and for loop but still i am getting error. --======Start...
1
by: Jon Haakon Ariansen | last post by:
Hi all, I don't know where to publish this question but hope this newsgroup is okey. I'm working in Visual Studio 2005 and are now creating a dataset file where I will do all the transactions...
9
by: fniles | last post by:
I am using VB.NET 2003 and SQL2000 database. I have a stored procedure called "INSERT_INTO_MYTABLE" that accepts 1 parameter (varchar(10)) and returns the identity column value from that table....
1
by: brianlanning | last post by:
We have a stored procedure that we've tried with two slightly different designs. It needs to take a 30 day date range and return a result set. Design 1 takes one date as a parameter. The other...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.