Hi there,

I'm a novitiate sybase developer. Can any expert give me any idea to solve following issue?

I would like to construct a dynamic sql that can return the result to the caller stored procedure as below:

stored procedure1:
select @mycount = 0
select @mytable = "sysobjects"
select @mytype = "P"
select @mysql = "select count(*) from " + @mytable + " where type = '" + @mytype + "'"
exec (@mysql)

After run above stored procedure1, how can I put the mysql exec return value to @mycount variable? I just think that I can put the result to #temp table, then the stored procedure1 can read the result in the same session. Is it a proper way to handle the return value?

Thanks in advance!