Friday, March 30, 2012

information_schema for temp table ?

Hi there!

I'm trying to find how can I get the information_schema for a temp table.

I'm trying to find all columns of a temp table.

So it will be something like this SELECT * FROM information_schema.columns

But it doesn't work for temp table, I tried tempdb.dbo.information_schema.columns ... nada...

Please help!

Thanks,

Or Thoi don't know what you are really trying to do but try...

SELECT * FROM #MyTempTable WHERE 1 = 0 will give the column names.

I know I do not want know the answer but why do you not know the structure of the temp table?|||I don't know the structure of my temp table because I use pivot tables.

And I transfer my data into an Excel worksheet using VB6. And when I do this, I loose all my columns name.

So it's a real pain in the a**.|||I don't know the structure of my temp table because I use pivot tables.

I am not sure why this matters. Store them in an array of variables and transfer them out too. ReDim sucks I know.

And I transfer my data into an Excel worksheet using VB6. And when I do this, I loose all my columns name.

it aint on the resume no more but i did some VB6 once upon a time. how are are you doing the export? There are a few ways to do this. Recently there was a thread here and there is some info on sqlteam about how to BCP out column names. Have you thought about using BCP?

However I am guessing you are doing the old Open #1 FOR OUTPUT or whatever it was or perhaps you are using filesystem objects.|||No I use CopyFromRecordSet of the Excel.Application.

What's BCP by the way ?

I am not sure why this matters. Store them in an array of variables and transfer them out too. ReDim sucks I know.

As I use a date as a pivot the number of columns still increase day by day|||bulk copy program. google it. or filesystem objects. heck google SQL Server DTS. Or "Visual Basic 6 Open file". I even bet if you check your VBA documentaion, you will find a way to do this. There are many ways to skin a cat.|||I did google the bulk copy, which is very intresting feature of sql.

I also checked at the vba documentions and no body mention how to do that or if it's doable... anyways ...

I'll try to find a way...

Thanks|||I found the best way to do it by myself, it was so easy lol... shame on me.|||enlighten us.|||As i said, I use it in a VB6 app that I made, and the results of the stored proc is stored in a record set so I build an array like this

array(#)= rs.fields(#).name...

It was SOOOO simple...

anyway... thank you all

No comments:

Post a Comment