Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old July 19th, 2005, 11:40 AM
Gervin
Guest
 
Posts: n/a
Default How to get the second table from sp_help result?

I am using SQL Server 2000 and I want to be able to list out all the field
names and their datatypes from a particular table.

I found out that sp_help does that but unfortunately when using a recordset,
I could only get the first of the 3 tables.

Is there anyway to get the second table using a recordset because that is
the one with all the info about the fields and their datatypes?

Or is there another way of finding out the datatypes of the fields?


  #2  
Old July 19th, 2005, 11:40 AM
Al Reid
Guest
 
Posts: n/a
Default Re: How to get the second table from sp_help result?

You move to the next 'Table' by using the "NextRecordset" method.

--
Al Reid

"It ain't what you don't know that gets you into trouble. It's what you know
for sure that just ain't so." --- Mark Twain

"Gervin" <gervin@pd.jaring.nospam.my> wrote in message news:bvqrff$cgt$1@news4.jaring.my...[color=blue]
> I am using SQL Server 2000 and I want to be able to list out all the field
> names and their datatypes from a particular table.
>
> I found out that sp_help does that but unfortunately when using a recordset,
> I could only get the first of the 3 tables.
>
> Is there anyway to get the second table using a recordset because that is
> the one with all the info about the fields and their datatypes?
>
> Or is there another way of finding out the datatypes of the fields?
>
>[/color]


  #3  
Old July 19th, 2005, 11:40 AM
Aaron Bertrand - MVP
Guest
 
Posts: n/a
Default Re: How to get the second table from sp_help result?

set rs = conn.execute("EXEC sp_help 'tablename'")

do while not rs.eof
response.write rs(0) & "<br>"
rs.movenext
loop

set rs = rs.nextRecordSet()
do while not rs.eof
response.write rs(0) & "<br>"
rs.movenext
loop

set rs = rs.nextRecordSet()
do while not rs.eof
response.write rs(0) & "<br>"
rs.movenext
loop


Also see the first example in http://www.aspfaq.com/2177 for a more concise
and exhaustive output, that doesn't require multiple resultsets.

--
Aaron Bertrand
SQL Server MVP
http://www.aspfaq.com/




"Gervin" <gervin@pd.jaring.nospam.my> wrote in message
news:bvqrff$cgt$1@news4.jaring.my...[color=blue]
> I am using SQL Server 2000 and I want to be able to list out all the field
> names and their datatypes from a particular table.
>
> I found out that sp_help does that but unfortunately when using a[/color]
recordset,[color=blue]
> I could only get the first of the 3 tables.
>
> Is there anyway to get the second table using a recordset because that is
> the one with all the info about the fields and their datatypes?
>
> Or is there another way of finding out the datatypes of the fields?
>
>[/color]


  #4  
Old July 19th, 2005, 11:41 AM
Gervin
Guest
 
Posts: n/a
Default Re: How to get the second table from sp_help result?

Thanks. I'll give it a try.

"Al Reid" <areidjr@reidDASHhome.com> wrote in message
news:%23%23eRmoy6DHA.488@TK2MSFTNGP12.phx.gbl...[color=blue]
> You move to the next 'Table' by using the "NextRecordset" method.
>
> --
> Al Reid
>
> "It ain't what you don't know that gets you into trouble. It's what you[/color]
know[color=blue]
> for sure that just ain't so." --- Mark Twain
>
> "Gervin" <gervin@pd.jaring.nospam.my> wrote in message[/color]
news:bvqrff$cgt$1@news4.jaring.my...[color=blue][color=green]
> > I am using SQL Server 2000 and I want to be able to list out all the[/color][/color]
field[color=blue][color=green]
> > names and their datatypes from a particular table.
> >
> > I found out that sp_help does that but unfortunately when using a[/color][/color]
recordset,[color=blue][color=green]
> > I could only get the first of the 3 tables.
> >
> > Is there anyway to get the second table using a recordset because that[/color][/color]
is[color=blue][color=green]
> > the one with all the info about the fields and their datatypes?
> >
> > Or is there another way of finding out the datatypes of the fields?
> >
> >[/color]
>
>[/color]


  #5  
Old July 19th, 2005, 11:41 AM
Gervin
Guest
 
Posts: n/a
Default Re: How to get the second table from sp_help result?

Thanks. I'll give it a try.



 

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles