Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Temp tables

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2002-02-28 : 08:20:27
Mala writes "Hi,

How can i get the list of column names of temporary tables creared within stored procedure. My SP will be some thing like this.

Create Proc Sp_abc
as

create #tmp_cl
(emp varchar(10),
....)

Now here at the end of the SP i want to list out all the columns created above , as some times i won't be knowing the column name as it will be created with dynamic values also.

I tried it in tempdb database. It worked with col_id(tablename) while i have to loop it to get each columns. But same things doesn't work in any other database. Please help.

Bye,
Mala"

Nazim
A custom title

1408 Posts

Posted - 2002-02-28 : 08:37:24
select * from tempdb..syscolumns where id=object_id('tempdb..#tt')
should give you the column names of temp table #tt.

HTH

--------------------------------------------------------------
Go to Top of Page
   

- Advertisement -