sql server - Insert data into temporary table from dynamic query table output -


i have below dynamic query run in sql server, connecting olap server using linked server, returns table result.

set @nsql = execute ('select non empty { [coded season].[coded season].[coded season] * [season].[season].[season] * [product].[subclass].[subclass] * [product].[subclass id].[subclass id] } on rows,{ [measures].[pl no of range opts] } on columns rp_c0') @ as_t_rp_5900_admin 

i executing in sql server this:

exec sp_executesql @nsql; 

it returns table of values. want insert data temporary table. have tried below code, not working.

insert ##subclass_season_as  exec sp_executesql @nsql; 

also tried,

set @strnewquery ='select '+@nsql+' ##temptablename ' exec @strnewquery 

could please on this? thanks!

you may want try put statement in dynamic query.

set @nsql = execute ('select non empty { [coded season].[coded season].[coded season] * [season].[season].[season] * [product].[subclass].[subclass] * [product].[subclass id].[subclass id] } on rows,{ [measures].[pl no of range opts] } on columns ##temptablename rp_c0') @ as_t_rp_5900_admin 

Comments

Popular posts from this blog

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -