var sidebar_align = 'right';
var content_container_margin = parseInt('290px');
var sidebar_width = parseInt('270px');
Unanswered: Return Result from Dynamic SQL
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:
select @mycount = 0
select @mytable = "sysobjects"
select @mytype = "P"
select @mysql = "select count(*) from " + @mytable + " where type = '" + @mytype + "'"
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!
i think the temp table is your only way...
so you can try :
create table #count (nbRows int null)
select @mycount = 0,
@mytable = "sysobjects",
@mytype = "P",
@mysql = "insert #count select count(*) from " + @mytable + " where type = '" + @mytype + "'"