Fetch from Temporary Table Incorrect syntax near for

I am trying to use a FETCH Statement to fetch from a temporary table and i keep getting a syntax error "incorrect syntax near for"  Can you use a FETCH statemnet on a temporary table?  Code below.

declare @field1 varchar(50)
declare @field2 varchar(50)
DECLARE @tblOrders Table  (
Table_ID INT IDENTITY,
LotNumber      varchar      (50)
)

DECLARE @mycursor CURSOR
for select * from @tblOrders

OPEN @mycursor

FETCH NEXT FROM @mycursor
INTO  @field1, @field2
WHILE @@FETCH_STATUS = 0

-- other processing here

CLOSE @mycursor
DEALLOCATE @mycursor
tegronakronAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Anthony PerkinsCommented:
Replace @mycursor with mycursor

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
sankarbhaCommented:
replace @mycursor with mycursor
Anthony PerkinsCommented:
In other words:

declare @field1 varchar(50)
declare @field2 varchar(50)
DECLARE @tblOrders Table  (
Table_ID INT IDENTITY,
LotNumber     varchar     (50)
)

DECLARE mycursor CURSOR
for select * from @tblOrders

OPEN mycursor

FETCH NEXT FROM mycursor
INTO  @field1, @field2
WHILE @@FETCH_STATUS = 0

-- other processing here

CLOSE mycursor
DEALLOCATE mycursor
Anthony PerkinsCommented:
Also, you are not using a temporary table, but rather a variable of type table.  
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server

From novice to tech pro — start learning today.