Hi All,

I have created a procedure which will updates statistics for all the tables in database. For that i have declared variable and cursors in it and passing table name from sysobjects table.
some of code is like as:

declare a_cur cursor for
select name from sysobjects where type ='U' order by name
open a_cur
fetch a_cur
into @a_name

while (@@sqlstatus = 0 )
select @msg = 'dbcc checktable ('+@a_name+')'
exec (@msg)

print "Completed ..."

fetch next a_cur
into @a_name


When i tryied to execute above procedure, I am getting following error:

dbcc checktable (titles)
Msg 11736, Level 15, State 0:
Server 'ASE15', Line 28:
line 1: You cannot specify this command in an 'execute immediate' context.

Now i want to ask whether there is any syntax error in this code or is there any other way to execute dbcc commands.
My aim is, I dont want to eecute dbcc commands individually through isql.

Platform: Windows/ ASE-15

Waiting for reply.
Thanks in advance.