Click to See Complete Forum and Search --> : adding identity colum in SQL temp table


bjswift
May 10th, 2006, 01:58 PM
I've got a table, in which I order it based on user input. Then, I need to take only certain user defined sections of data, such as rows 0-100, 101-200, 201-300 ect.. ect..

I order the table and throw it into a temp table using;
select bla bla bla into #tempTable from bla bla bla

Then, I add an identity so I can number the rows in an order from first to last, using;
alter table #tempTable add ID int indentity

I am able to select * from #tempTable and the ID is there, but if I write a where ID > X it fails with this message:

Invalid column name 'ID'.

Whats the deal!?