bjames
asked on
SQLCODE
What is wrong with this syntax? I've written this in Query Analyzer (7.0 beta) and when I attempt to run it I get an "Incorrect syntax near '='." error.
--My Code
declare cProcList cursor for
select name from sysobjects
where xtype = 'P'
and name > 'du'
order by name
open cProcList
while (SQLCODE == 0)
(
fetch cProcList
)
close cProcList
--My Code
declare cProcList cursor for
select name from sysobjects
where xtype = 'P'
and name > 'du'
order by name
open cProcList
while (SQLCODE == 0)
(
fetch cProcList
)
close cProcList
ASKER
That is the way the example until FETCH in Books On-Line shows it. And when I change the == to a single = I get another error:
Incorrect syntax near the keyword 'fetch'.
Incorrect syntax near the keyword 'fetch'.
I don't have the SQL 7 BOL with me right now, but the parenthesis around the fetch look suspicious. I've not spent a lot of time with SQL 7, so maybe they've added that syntax... try begin/end instead:
while (SQLCODE = 0)
begin
fetch cProcList
end
while (SQLCODE = 0)
begin
fetch cProcList
end
ASKER
That gives me a new error.
Invalid column name 'SQLCODE'.
Invalid column name 'SQLCODE'.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks. It works great. Sorry for the trouble. I'm still new to SQL Server.
No trouble at all. Enjoy SQL 7!
Why do you have two 'equal' signs?