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
 General SQL Server Forums
 New to SQL Server Programming
 Unique id in views

Author  Topic 

jaypee_s
Starting Member

22 Posts

Posted - 2007-10-23 : 07:18:18
I have to create a unique id in a view, How to achive this....Please help

Kristen
Test

22859 Posts

Posted - 2007-10-23 : 07:21:52
If you are using SQL 2005 then possibly: ROW_NUMBER()
Go to Top of Page

jaypee_s
Starting Member

22 Posts

Posted - 2007-10-23 : 07:22:50
i am using sql 2000, is it possible in sql 2000.
Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2007-10-23 : 07:30:21
No, in SQL 2000 the only way I know is to query into a Temporary Table which has an additional IDENTITY column, and then "display" from that Temp Table.

Unless someone else knows otherwise

Kristen
Go to Top of Page

jaypee_s
Starting Member

22 Posts

Posted - 2007-10-23 : 07:34:06
Thanks for your information.
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-10-23 : 08:23:00
An ID must not always be integer.
If your ID is UNIQUEIDENTIFIER, use NEWID() function.

If ID is integer, you could use correlated subquery with DISTINCT but that would really kill performance.


E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2007-10-23 : 08:45:24
quote:
Originally posted by Kristen

No, in SQL 2000 the only way I know is to query into a Temporary Table which has an additional IDENTITY column, and then "display" from that Temp Table.

Unless someone else knows otherwise

Kristen


If serial number is important, then do numbering at front end

Madhivanan

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

Kristen
Test

22859 Posts

Posted - 2007-10-23 : 09:08:33
"If serial number is important, then do numbering at front end"

Can't get ORDER BY in the view [itself] either (well, you CAN but your SHOULDN'T and it will give trouble under SQL 2005 IIRC)

Kristen
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2007-10-23 : 11:29:08
Umm, what are you going to use this id for?



Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx

Add yourself!
http://www.frappr.com/sqlteam



Go to Top of Page
   

- Advertisement -