Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Probably very simple StorProc Question

Status
Not open for further replies.

uncLez

Programmer
Jun 18, 2002
38
NL
Hi all,
this is probably very simple, but I just can't seem to find it in the online books and my Stored Procedure book.

In a Stored Procedure I am writing I need to use the result of the sp_columns system stored procedure. More specifically the Type_Name property.

How do I do this? How can I select just this property? I get the result set already, but how to page through it? Can I declare a cursor for this? For instance like

Code:
Declare stpcursor cursor FOR EXEC sp_columns @table_name = 'tablename', @column_name = 'columnname'

Or could I somehow retrieve te information more easily with the dbo.tablename.columnname.datatype property? That would ofcourse be easiest, but can it be done? If so, HOW??? :)

Thanx in advance,
Anton.
 
Use the Information Schema views.

Select Table_Name, Column_Name, Type_name
From information_schema.tables
Where table_name='tablename' Terry L. Broadbent - DBA
Computing Links:
faq183-874 contains "Suggestions for Getting Quick and Appropriate Answers" to your questions.
 
Something like this:

select column_name,data_type from information_schema.columns
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top