• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 11670
  • Last Modified:

RowId In SQL Server

How can i get the "RowId" of a table in Sql Server?
0
pradeepaga
Asked:
pradeepaga
  • 2
1 Solution
 
illCommented:
sql server 2000 doesn't support rowID.
0
 
danblakeCommented:
There is no such thing as a RowId of a table in sql-server as an inbuilt function there is something called ROWGUIDCOL but this is something completly different.
Yukon is going to introduce a RowID functionality that is the similar to Oracle's RowId property
(RowID is an Oracle function -- that does not exist in SQL-Server).

This is normally acomplised in SQL-Server by adding an identity column (1,1) and calling it RowId
(But I wouldn't want to call it a RowID -- reserved word).

0
 
danblakeCommented:
Have a look here for the identity column implementation:
http://www.sql-server-performance.com/forum/topic.asp?TOPIC_ID=3385

0
 
arbertCommented:
I agree that the identity method is usually the easiest way.  If you don't already have an identity column on your table, you can always insert into  a temp table and return the results.  If you do already have an identity column on your table and you can't have a gap between the numbers, you could also create a UDF that joins back to your original table and sequence the records that way.

Brett
0

Featured Post

Veeam and MySQL: How to Perform Backup & Recovery

MySQL and the MariaDB variant are among the most used databases in Linux environments, and many critical applications support their data on them. Watch this recorded webinar to find out how Veeam Backup & Replication allows you to get consistent backups of MySQL databases.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now