sql-server-2000

How can I do server side pagination of results in SQL Server 2000?

主宰稳场 提交于 2020-01-07 04:57:27
问题 In SQL Server 2005, there is a feature called row_number() which makes pagination very simple. SELECT * FROM table WHERE row_number() between x and y Is there any SQL server way to do the same thing in SQL Server 2000? (Note: I don't have access to a unique sequential numbering for the query, i.e. something which would be a synonym for row_number()) 回答1: SELECT * FROM ( SELECT TOP (Y - X ) * FROM ( SELECT TOP Y * FROM mytable ORDER BY column ) q ORDER BY column DESC ) ORDER BY column 回答2: Not

T-SQL Calculate Percentage

喜夏-厌秋 提交于 2020-01-06 18:07:27
问题 I have a SQL Server (2000) database with customers (health club). The customers join on a yearly basis. I want to be able to calculate the percentage of customers who renew there membership (over time and an the past current year). The Active Status field indicates whether they are still a member. The JoinDate doesn't change. When a member renews there is an ActiveDate and also a DueDate (when a customer is due to renew), the DueDate is 1 year ahead of the Active Date. What I am looking to do

sql loop through results / group by / sort

早过忘川 提交于 2020-01-05 08:07:43
问题 this is a follow on question from my previous post I have the following code which will query a database of when our agents were logged on at a particular time. It works nicely for a given day, but I need to now do it for a selected time period. I am not sure where to start to adjust this! I'd need the results grouped by date and hour... so it would look as follows date hour count 10/10/11 22 52 10/10/11 23 24 11/10/11 00 12 11/10/11 01 33 So the 24 hour period would be displayed for each

Time out error while executing the query

霸气de小男生 提交于 2020-01-05 07:55:51
问题 I am executing the following query in a stored procedure, transferring one year's transactions from one table to another: insert into table2 select * from table1 where dates between '20110101' and 20111231' When I use VB6 to call the stored procedure, it times out. I've tried to set the QueryTimeout property on my RDO Connection to five seconds like so: RdoConn.QueryTimeout = 5000 But it's still timing out. How can I prevent the execution of the query from timing out? 回答1: If you use an Ado

SQL Server 2000: Why is this query w/ variables so slow vs w/o variables?

倾然丶 夕夏残阳落幕 提交于 2020-01-05 05:30:10
问题 I can't figure out why this query would be so slow with variables versus without them. I read some where that I need to enable "Dynamic Parameters" but I cannot find where to do this. DECLARE @BeginDate AS DATETIME ,@EndDate AS DATETIME SELECT @BeginDate = '2010-05-20' ,@EndDate = '2010-05-25' -- Fix date range to include time values SET @BeginDate = CONVERT(VARCHAR(10), ISNULL(@BeginDate, '01/01/1990'), 101) + ' 00:00' SET @EndDate = CONVERT(VARCHAR(10), ISNULL(@EndDate, '12/31/2099'), 101)

Database design help with varying schemas

亡梦爱人 提交于 2020-01-05 04:26:10
问题 I work for a billing service that uses some complicated mainframe-based billing software for it's core services. We have all kinds of codes we set up that are used for tracking things: payment codes, provider codes, write-off codes, etc... Each type of code has a completely different set of data items that control what the code does and how it behaves. I am tasked with building a new system for tracking changes made to these codes. We want to know who requested what code, who/when it was

How to Search date in SQL?

∥☆過路亽.° 提交于 2020-01-04 01:49:16
问题 I am having an Event Management System in which i want, If an event is registered for 5 days (21 jan 2009 to 26 Jan 2009) Then if another person wants to register an event between 22 jan 2009 to 24 jan 2009 then it will not allow to register. I want to check this using SQL query, so please tell me how can i do this. 回答1: SELECT * FROM events e WHERE (@startDate BETWEEN e.startDate and e.endDate) OR (@endDate BETWEEN e.startDate and e.endDate) OR (@startDate < e.startDate AND @endDate > e

How to Search date in SQL?

被刻印的时光 ゝ 提交于 2020-01-04 01:49:10
问题 I am having an Event Management System in which i want, If an event is registered for 5 days (21 jan 2009 to 26 Jan 2009) Then if another person wants to register an event between 22 jan 2009 to 24 jan 2009 then it will not allow to register. I want to check this using SQL query, so please tell me how can i do this. 回答1: SELECT * FROM events e WHERE (@startDate BETWEEN e.startDate and e.endDate) OR (@endDate BETWEEN e.startDate and e.endDate) OR (@startDate < e.startDate AND @endDate > e

HRESULT: 0x8004D00E using TransactionScope - C#

随声附和 提交于 2020-01-03 19:14:21
问题 I received the following error when I tried to run a C# WinForms application on a Windows Server 2003 Standard Edition SP1 machine that was connecting to a SQL server 2000, converting the data in the WinForms app and inserting the converted into a SQL server 2005 application. I am connecting to each database using SSPI. The code was contained within a TransactionScope block: System.TimeSpan TransactionTimeOut = new TimeSpan(0, 40, 0); using(TransactionScope Scope = new TransactionScope

11 seconds to delete 240 rows in SQL Server

你离开我真会死。 提交于 2020-01-03 09:08:17
问题 i am running a delete statement: DELETE FROM TransactionEntries WHERE SessionGUID = @SessionGUID The actual execution plan of the delete is: Execution Tree -------------- Clustered Index Delete( OBJECT:([GrobManagementSystemLive].[dbo].[TransactionEntries].IX_TransactionEntries_SessionGUIDTransactionGUID]), WHERE:([TransactionEntries].[SessionGUID]=[@SessionGUID]) ) The table is clustered by SessionGUID , so the 240 rows are physically together. The table has no triggers on it. The operation