From: Sceren on

I have some script where i create a temp table in sql 2k5 such as

create table #tmp
usrlogin varchar(10)

I then insert data into this temp table and run an alternate query that
deletes some of the rows...

Next i add an identity column so i can use it for a while loop as opposed to
a cursor.

alter table #tmp add row_id int identity(1,1)

The problem is it doesnt execute the ddl statement above in my script. I
know that sql server determines a query execution plan and might run some
things out of order. I tried separating with the go statement and even
created as a stored procedure and created the statement as dynamic sql and
executed it via exec sp_executesql but it still wont execute with any of
those methods.

So when it gets to the point where i use the column row_id the script bombs
out with an invalid column error.

what am i doing wrong?

-D Sceren
Pages: 1
Prev: ddl not working in scrip
Next: basic join question