L
litian2
Unregistered / Unconfirmed
GUEST, unregistred user!
begin trandeclare @tabname varchar(20)declare mycursor cursor forselect name from sysobjects where xtype='u' open mycursorfetch next from mycursor into @tabnamewhile @@fetch_status=0 begin--------问题在这里----------- if exists (select * from @tabname) print @tabname----------------------------- fetch next from mycursor into @tabnameendclose mycursordeallocate mycursorif @@error<>0 rollback tranelse commit tran语句如上,在上面的问题部分我想要判断列举出的表哪个有数据,然后打印出来,可是用上面的语句提示必须声明变量 '@tabname',可能不能用select加变量名称,请各位朋友帮忙解决,或能给出实现相应功能的语句