Hi
I have a question regarding SLQ variables. I am setting the variable through a cursor. When I check the syntax of this SQL, it says that I need to declare @TableName on the line that says
select @eid = eid from @tableName . Is it not possible to do this? I know that I've used such variable in a where clause. Is it because I am using it in a from clause? Do I need some other kind of syntax to do this?

declare @elementClassId int,
@eid eid,
@className varchar(32),
@tableName varchar(32),
@aid eid,
@attributeName varchar(32)

declare classCursor cursor for
select classId, TableName from tmbElementClasses where classAttributes = 3
order by TableName

open classCursor
fetch classCursor into @elementClassId, @tableName
while (@@fetch_status = 0)
BEGIN

if( @elementClassId is not NULL and @tableName is not NULL )
begin
select @eid = eid from @tableName
end
fetch classCursor into @elementClassId, @tableName

END
close classCursor
deallocate classCursor

Thanks in advance