sql-server-2000

What is a good way to paginate out of SQL 2000 using Start and Length parameters?

自闭症网瘾萝莉.ら 提交于 2019-12-04 17:53:46
I have been given the task of refactoring an existing stored procedure so that the results are paginated. The SQL server is SQL 2000 so I can't use the ROW_NUMBER method of pagination. The Stored proc is already fairly complex, building chunks of a large sql statement together before doing an sp_executesql and has various sorting options available. The first result out of google seems like a good method but I think the example is wrong in that the 2nd sort needs to be reversed and the case when the start is less than the pagelength breaks down. The 2nd example on that page also seems like a

How to duplicate a SQL Server 2000 table programatically using .NET 2.0?

梦想的初衷 提交于 2019-12-04 17:15:20
I want to backup a table saving the copy in the same database with another name. I want to do it programatically using .NET 2.0 (preferably C#). Someone can point me what should I do? Just send this query to the server: SELECT * INTO [BackupTable] FROM [OriginalTable] This will create the backup table from scratch (an error will be thrown if it already exists). For large tables be prepared for it to take a while. This should mimic datatypes, collation, and NULLness (NULL or NOT NULL), but will not copy indexes, keys, or similar constraints. If you need help sending sql queries to the database,

SQL Server printf

删除回忆录丶 提交于 2019-12-04 17:03:50
问题 Is there a printf-like function in Sql Server? I want the same features as the RAISERROR function, but instead of throwing an error, or printing a message, I want to write it in a varchar , because my ERP won't let me handle the error messages. This is SQL Server 2000. Actual working example with RAISERROR: declare @name varchar(10) set @name = 'George' RAISERROR ('Hello %s.', 10, 1, 'George') prints Hello George What I'm looking for: declare @name varchar(10), @message varchar(50) set @name

SQL: how to select common lines of one table on several column

六眼飞鱼酱① 提交于 2019-12-04 16:16:41
I have a table : create table a (page int, pro int) go insert into a select 1, 2 insert into a select 4, 2 insert into a select 5, 2 insert into a select 9, 2 insert into a select 1, 3 insert into a select 2, 3 insert into a select 3, 3 insert into a select 4, 3 insert into a select 9, 3 insert into a select 1, 4 insert into a select 9, 4 insert into a select 12, 4 insert into a select 1, 5 insert into a select 9, 5 insert into a select 12, 5 insert into a select 13, 5 insert into a select 14, 5 insert into a select 15, 5 go (here is the SQLfiddle of this table and queries I began to write )

SQL Server, choosing from two TABLEs using IF statement inside WHERE statement depending on the parameter

混江龙づ霸主 提交于 2019-12-04 15:44:21
How can I do the following in SQL Server DECLARE @Local nvarchar(20) SET @Local = 'True' SELECT * FROM My_Table WHERE my_ID IN (IF @Local = 'True' SELECT AllIDs FROM ATable ELSE SELECT TeamIDs FROM TeamTable ) Go for a union :- SELECT * FROM My_Table WHERE my_id IN ( SELECT AllIDs AS MyIDs FROM ATable WHERE @Local = 'True' UNION SELECT TeamIDs AS MyIDs FROM TeamTable WHERE @Local <> 'True' ) SELECT * FROM mytable WHERE my_id IN ( SELECT allids FROM atable WHERE @Local = 'True' ) UNION ALL SELECT * FROM mytable WHERE my_id IN ( SELECT teamids FROM teamtable WHERE COALESCE(@Local, '') <> 'True'

Query performance of combined index vs. multiple single indexes vs. fulltext index

半城伤御伤魂 提交于 2019-12-04 14:06:53
问题 Background: I have a table with 5 million address entries which I'd like to search for different fields (customer name, contact name, zip, city, phone, ...), up to 8 fields. The data is pretty stable, maximum 50 changes a day, so almost only read access. The user isn't supposed to tell me in advance what he's searching for, and I also want support of combined search (AND-concatenation of search terms). For example "lincoln+lond" should search for all records containing both search terms in

Is there any way/tool to identify estimate query run time in SQL sERVER

两盒软妹~` 提交于 2019-12-04 13:15:38
I have been google about this for a while..is there any way to identify the estimated query execution time> There are actual execution plan and estimated execution plan on the ssms .The thing is none of these have estimated time. Is it something lacking in the Sql Server? Peter Currently, no. Microsoft is currently researching ways to do this using a combination of work already completed and an estimated execution plan (See the details of their research on the Microsoft Research site ), so we can expect to see something soon. But this is the only development that I am aware of. The solution I

SQL Server 2000 - Breaking a query up into 15 minute blocks

假如想象 提交于 2019-12-04 12:41:35
I have a continous time dataset and I want to break it up into 15 minute blocks using sql. I don't want to have to create a new table to be able to do this if I can help it. i.e. Time, Count 09:15, 1 09:30, 3 09:45, 0 10:00, 2 10:15, 3 ..... Does anyone have any idea of how I can do this. I presume that is use a select similar to the following: SELECT [Some kind of data manipulation on "MyDate"] , COUNT(ID) FROM MyTable GROUP BY [Some kind of data manipulation on "MyDate"] With careful use of dateadd and datediff, this can be accomplished. My solution rounds the times down. The first piece

How can I check for average concurrent events in a SQL table based on the date, time and duration of the events?

我的未来我决定 提交于 2019-12-04 09:34:49
问题 I have a set of call detail records, and from those records, I'm supposed to determine the average concurrent active calls per system, per hour (at a precision of one minute). If I query 7pm to 8pm, I should see the average concurrent calls for the hour (averaging the concurrent calls for each minute) within that hour (for each system). So, I need a way to check for a count of active calls for 7:00-7:01, 7:01-7:02, etc then average those numbers. A call is considered active if the call's time

Get list of tables but not include system tables (SQL Server 2K)?

天大地大妈咪最大 提交于 2019-12-04 08:38:56
I know I can get a list of tables from a given database with the following query: select * from information_schema.tables How do I go about excluding system tables though? select name from sysobjects where type='U' Damien_The_Unbeliever I know this is quite an old question, but someone's just edited it to resurrect it, and the "right" answer from my perspective isn't either of the two listed. The accepted answer includes some "system" tables ( dtproperties is mentioned in the comments. If the user had any replication going on, they'd have found a few more). The other answer uses a 2005 table,