Hello, this is my first post here, i hope i'll find this forum usefull.
Although i did a search about my question, i didnt find what i need , because the question isnt exactly what it sounds.
Here's my scenario
I have a table that doesnt have an identity column, but does have unique rows depending on a combination of two columns.
the table's name is carowner and the two columns i am talking about are iteid,cusid and they are both of datatype int. what i need to do is to add to the existing data of the table a linenumber per iteid. for example i could have the following two records
iteid | cusid
6668 | 1
6668 | 2
6669 | 1
6669 | 4
what i wanna do is add a column so that the above data would look like this
iteid | cusid | Linenum
6668 | 1 | 1
6668 | 2 | 2
6669 | 1 | 1
6669 | 4 | 2
So i need to number the records depending on the column iteid and i need to do that for the existing data but also for every new record inserted into the table.
I was thinking this could be done by adding a trigger to the table but i am not sure on how to do this.
Any help woould be greatly appriciated, so many thanx in advance.
Although i did a search about my question, i didnt find what i need , because the question isnt exactly what it sounds.
Here's my scenario
I have a table that doesnt have an identity column, but does have unique rows depending on a combination of two columns.
the table's name is carowner and the two columns i am talking about are iteid,cusid and they are both of datatype int. what i need to do is to add to the existing data of the table a linenumber per iteid. for example i could have the following two records
iteid | cusid
6668 | 1
6668 | 2
6669 | 1
6669 | 4
what i wanna do is add a column so that the above data would look like this
iteid | cusid | Linenum
6668 | 1 | 1
6668 | 2 | 2
6669 | 1 | 1
6669 | 4 | 2
So i need to number the records depending on the column iteid and i need to do that for the existing data but also for every new record inserted into the table.
I was thinking this could be done by adding a trigger to the table but i am not sure on how to do this.
Any help woould be greatly appriciated, so many thanx in advance.
Comment