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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Concatenating fields

Status
Not open for further replies.

tooold

Programmer
Oct 18, 2002
4
US
I would like to loop thru a selection set and create a single string from all of the records to be returned as an OUTPUT var. The first step is to concatenate all of the fields of each record into a string. This can be done by individually stating each field in the SELECT statement and using CAST(), but SP would have to be edited whenever column names change or columns are added/dropped. So I would like to refer to the columns by their ordinal number and then extract their value into the string. I have found ways to get the column *name* via system table queries and an ordinal value , but not how to get the column *value* based on an ordinal value.

Is there any other way to do this without resorting to dynamic SQL statements?

Thanks for your help.
 
I think that you will have to first get the column names based upon the number and then get the field values based upon the column names.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top