|
database
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Table results from Exec - Within a UDFHi all,
I have a question on how to obtain the results of a exec out of a UDF/Stored Proc? Currently I haev a UDF that builds a select statement and executes it using the [I wanted to return the Statement itself, but was too big for varchar] return @sqlStatement I then tried 'select * into #temp from (exec @sqlStatement) -- didn't work. why am I doing this? - I want to use the result of this query in another query that I have in a stored proc. Any ideas will be helpful. thanks If I confused you all, here is the question in an easy form:
How do I read the contents of a "exec @mySqlQuery" into a temp table? try
insert into #sometable exec('some query') Make sure you define the schema of the temp table before doing it (its an "insert into" thing and not "select into insert") hope this helps. otherwise post your query and some would be able to give you a suggesstion. and ya you can do the above thing to store the ouput of a sproc into a temp table as well. Do let me know if this solves your problem Abhishek Show quote "adi" wrote: > If I confused you all, here is the question in an easy form: > > How do I read the contents of a "exec @mySqlQuery" into a temp table? > > Right, UDF did not work but I palced this stuff in a Stored Proc and it
looks good. CREATE TABLE ##tempTable ( id varchar(9), field_id varchar(50), value varchar(8000)) insert ##tempTable exec(@tempSql) thank you! |
|||||||||||||||||||||||