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.
| 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() |
 |
|
|
jaypee_s
Starting Member
22 Posts |
Posted - 2007-10-23 : 07:22:50
|
| i am using sql 2000, is it possible in sql 2000. |
 |
|
|
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 |
 |
|
|
jaypee_s
Starting Member
22 Posts |
Posted - 2007-10-23 : 07:34:06
|
| Thanks for your information. |
 |
|
|
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" |
 |
|
|
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 MadhivananFailing to plan is Planning to fail |
 |
|
|
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 |
 |
|
|
X002548
Not Just a Number
15586 Posts |
|
|
|
|
|
|
|