472,805 Members | 1,395 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes and contribute your articles to a community of 472,805 developers and data experts.

Getting rownumber in View in SQL2000

Yes In SQL2000 , Row_Number() function will not work as in SQL2005.
But, we can use the IDENTITY(INT,1,1) function but it requires a temporary table to which it stores the data and in View does'nt Support Temporary tables.

what I did is, I created a function which returns a table and in that table I have but 1 Identity field with AutoIncrement...
Sample Code
****************
ALTER FUNCTION dbo.UF_GetName()

RETURNS @Temp_tbl TABLE (
[RowNumber] [int] IDENTITY (1, 1) NOT NULL ,
[Name] [nvarchar] (100) COLLATE SQL_Latin1_General_CP1_CI_AS NULL )
AS
BEGIN

INSERT INTO @Temp_tbl (Name)
SELECT
Name
FROM
Users
WHERE
Name like 'a%'

ORDER BY Name


RETURN

END

GO

************************************************** ***************************

Now, you can use this function in the stored procedure or views and you want to ... and the RowNumber in the table will give you the RowNumbers for ur query Result...

SampleCode
****************

Create View View_GetName
as
SELECT TOP 100 PERCENT RowNumber,Name FROM dbo.UF_GetName()
WHERE RowNumber BETWEEN 1 AND 100

********************

then Execute the View u will get the result...


I Hope this post might help someone, who is trying to create view in sql2000 and wants the rownumber in the result.

Cheers !!!
Vineet CS
Oct 29 '09 #1
0 4333

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

Similar topics

17
by: John Hunter | last post by:
I have a largish data set (1000 observations x 100 floating point variables), and some of the of the data are missing. I want to try a variety of clustering, neural network, etc, algorithms on the...
4
by: Richard Holliingsworth | last post by:
Hello: I have an Access 2K form I built from a SQL Server 7.0 view. I want to lock certain fields in the database from users so they can see them on the views and forms, but NOT be able to edit...
2
by: jc | last post by:
Hi. A question I have is with regard to the use of views with SQL2000. If I have a view called "A_view" and used in the following manner; ---------------- SELECT ... FROM A_View WHERE .... ...
5
by: Paul Reddin | last post by:
Hi, using ROWNUMBER() is affecting the plan of a view very badly... is there a way of writing the following view to ensure rownumber() is done as the last thing done? i.e after the calling...
6
by: vbmark | last post by:
I have the follwing XML string: <RecordSet> <Row RowNumber="1"> <UserID>111</UserID> <Phone>1234567890</Phone> </Row> <Row RowNumber="2"> <UserID>747</UserID> <Phone>9876543210</Phone>
3
by: V T | last post by:
Hello all, SQL Server 2000 documentation http://www.microsoft.com/technet/prodtechnol/sql/2000/reskit/part10/c3761.mspx states that if view is using "NOT NULL" columns of a base table, then...
5
by: Grzegorz Danowski | last post by:
Hi I have two databases: Customers and Operations. In Customers database I have made a view based on a few tables from both Customers and Operations (left join - customers without any...
2
by: PointMan | last post by:
i make a project in vs2005 that use ASPNETDB.MDF and use <asp:LoginView ID="LoginView1" runat="server" > server control for vs2005 in this case , i'd like to use hosting service but this...
2
by: =?Utf-8?B?TWFyYw==?= | last post by:
In Visual Studio 2005, I am developing a Windows Mobile application, using Mobile SQL 2005. I need Data from a Database to be shown in a DataGrid, this works. But now I want to be able to get the...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: erikbower65 | last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps: 1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal. 2. Connect to...
0
linyimin
by: linyimin | last post by:
Spring Startup Analyzer generates an interactive Spring application startup report that lets you understand what contributes to the application startup time and helps to optimize it. Support for...
0
by: kcodez | last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Sept 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
14
DJRhino1175
by: DJRhino1175 | last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this - If...
0
by: Rina0 | last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
0
by: lllomh | last post by:
How does React native implement an English player?
0
by: Mushico | last post by:
How to calculate date of retirement from date of birth

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.