Two part question regarding partitioning in SQL.
In T-SQL when you use PARTITION BY is there a way to assign a unique number to each partition, in addition to something
You could use dense_rank():
dense_rank()
select * , row_number() over (partition by Action order by Timestamp) as RowNum , dense_rank() over (order by Action) as PartitionNum from YourTable
Example at SQL Fiddle.
T-SQL is not good at iterating, but if you really have to, check out cursors.