|
Posted by GM on 10/01/12 11:28
Hello all, i have a question i've beenk thinking for a little bit and
cant seem to come up with a solution. What i want to do is add a unique
counter to a resultset in query. For example
SELECT ColumnA, ColumnB, ColumnC, ColumnD
FROM AnyCombinationOfJoinsOrTables
WHERE SomeConditionIsTrue
w
The query above will produce a resultest of 4 columns.
'A1', 'B1', 'C1', 'D1'
'A2', 'B2', 'C2', 'D2'
'A3', 'B3', 'C3', 'D3'
......
'An', 'Bn', 'Cn, 'Dn'
Now what i want to do is add a unique identifier to every row. The
easiest way would be to add a counter integer so the resultset would
look like
1, 'A1', 'B1', 'C1', 'D1'
2, 'A2', 'B2', 'C2', 'D2'
3, 'A3', 'B3', 'C3', 'D3'
......
n, 'An', 'Bn', 'Cn, 'Dn'
Is there a way to achieve this in T-SQL without using cursors.
Thanks,
Gent
Navigation:
[Reply to this message]
|