Board index » delphi » StoredProc and Temporary Tables doesn't work?

StoredProc and Temporary Tables doesn't work?

I'm trying to retrieve a recordset from a storedprocedure (SQLServer 7.0)
that create a temporary table and return his data. But I got the erro:
"CommandText does not return a result set." ????

How can I do it?

This is an example of a storedprocedure:
--------------------------------------------

CREATE procedure get_students
   @cod_student int
as

CREATE TABLE #temp1 (cod int NOT NULL, name char(50) NOT NULL)
CREATE UNIQUE INDEX MyIndex ON #temp1(cod)

INSERT INTO #temp1
select cod_student, name_student
from students
where cod_student <= @cod_student

SELECT * FROM #temp1

--------------------------------------------

Thanks.
Fabricio.

 

Re:StoredProc and Temporary Tables doesn't work?


Try insert begin ... end

CREATE procedure get_students
   @cod_student int
as
begin
  CREATE TABLE #temp1 (cod int NOT NULL, name char(50) NOT NULL)
  CREATE UNIQUE INDEX MyIndex ON #temp1(cod)

  INSERT INTO #temp1
  select cod_student, name_student
  from students
  where cod_student <= @cod_student

  SELECT * FROM #temp1
end

"Fabricio" <fabri...@qualidata.com.br> ???Y/???Y ?????
???Y??: news:3bb21149_2@dnews...

Quote
> I'm trying to retrieve a recordset from a storedprocedure (SQLServer 7.0)
> that create a temporary table and return his data. But I got the erro:
> "CommandText does not return a result set." ????

> How can I do it?

> This is an example of a storedprocedure:
> --------------------------------------------

> CREATE procedure get_students
>    @cod_student int
> as

> CREATE TABLE #temp1 (cod int NOT NULL, name char(50) NOT NULL)
> CREATE UNIQUE INDEX MyIndex ON #temp1(cod)

> INSERT INTO #temp1
> select cod_student, name_student
> from students
> where cod_student <= @cod_student

> SELECT * FROM #temp1

> --------------------------------------------

> Thanks.
> Fabricio.

Other Threads