Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Creating Views or any other ideas

Author  Topic 

kalyformin
Starting Member

15 Posts

Posted - 2006-12-08 : 18:51:01
Hello,

I'm quite to new creating Views in SQL Server so I dont know if anything like this is possible at all. We have a database table with 300,000 rows. We need to create a view with some fields from this table along with a column indicating something like a RowID.(more or less like an IDENTITY column). Is it possible to create a view with the data like above ?

OR

Any other suggestions or thoughts are welcome (except using temp tables)

Thanks for all advance help

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2006-12-08 : 23:10:41
If you are using SQL 2005, you can use ROW_NUMBER()
In case of SQL 2000, something like this will work but this is not the efficient way:

Create View v1
as
Select
(Select count(*) from Tbl t2 where t2.SomeCol <= t1.SomeCol) as RowID,
Col2, col3,...
From Tbl t1
Order by SomeCol


Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-12-09 : 02:45:39

1 If you use front end application to display data, do numbering there
2 If you use sql server 2005, you can make use of ROW_NUMBER()

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -