cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Dynamic SQL Execution from Temp Table

Former Member
0 Likes
1,271

Dear Experts,

I have some scenarios where i have to run some sql queries dynamically , i went through many threads and found some useful and tried to use them but unfortunately i am still not done with this.

below is my code i want to execute

Regards,

Manish

drop procedure DNsql;
CREATE PROCEDURE DNsql (out  Account nvarchar(200))
LANGUAGE SQLSCRIPT
AS
  SQL1 nvarchar(200) := '';
BEGIN
create LOCAL TEMPORARY TABLE "#temp" (Accnt nvarchar(200));
SQL1:='insert into "#temp" SELECT 'SELECT'||'  '||' '|| '"Account"' ||' '||'FROM'||' '||SCHEMA_NAME||'.'||'JDT1' 
FROM schemas WHERE SCHEMA_NAME LIKE 'SBK%%%%'';
exec SQL1;
select  Accnt into Account from "#temp";
DROP TABLE "#temp";
END;

Accepted Solutions (0)

Answers (0)