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 |
|
klunevich
Starting Member
1 Post |
Posted - 2005-01-17 : 12:21:15
|
| I am trying to make an automatically incremented value as an indentifying column created in a view. This value is not pulled from any of the existing database information (There is no database column that I can use as an indentifying column). It can start at 1 and continue up from there.A basic example of my view would be as follows (I need the pkID to be the identifying column):Select '' as pkID, FirstName, LastName From TableNameThanks,Keith |
|
|
robvolk
Most Valuable Yak
15732 Posts |
Posted - 2005-01-17 : 12:24:58
|
| I suggest looking at these:http://www.sqlteam.com/searchresults.asp?SearchTerms=row+numberAlthough I think you're going to have problems using them in a view. For one thing, not having any identifying data in the table will make it impossible to number duplicate rows properly. And adding this "identifying column" isn't identifying anything, it's simply numbering the rows. |
 |
|
|
rockmoose
SQL Natt Alfen
3279 Posts |
Posted - 2005-01-17 : 16:28:51
|
You know you should have a primary key on your table don't you ?This is not guaranteed to be unique, but I would not be too concerned in your case.select cast(cast(newid() as binary(16)) as bigint) as pkID, FirstName, LastName From TableName rockmoose |
 |
|
|
|
|
|