Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7666629
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T14:52:52+00:00 2026-05-31T14:52:52+00:00

I have a function that produces a few rows as string values. The values

  • 0

I have a function that produces a few rows as string values. The values are as follows:

[12*02]
[12*03]
[12*04]
[12*05]
[12*06]
[12*07]
[12*08]
[12*09]
[12*10]
[12*11]
[12*12]
[12*13]
[12*14]
[12*15]

The values are actually different rows. So [12*01] is row 1 and [12*02] is row # 2 and so on.
I want to use these values as column headers. So [12*01] is column 1 and [12*02] is column 2 and so on. I would have used a pivot but this string will keep changing every time and thats the very reason I dont want to use pivots. This is not a college homework assignment, and I have only thought of using RANK and row number functions.

Any help would be appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T14:52:54+00:00Added an answer on May 31, 2026 at 2:52 pm

    You will still have to use pivot (or aggregate_function (CASE ) hand-coded variant), but you can do it dynamically. Create a procedure accepting a comma-separated list of column headers and prepare sql code for pivot in varchar variable placing a placeholders where a list should be. This allows you to save pivot code in a table, or read a view definition into varchar variable to help you with syntax checking. After that replace placeholders with actual list and execute pivot.

    create proc ExecPivot (@PivotedList nvarchar(max))
    as
       set nocount on
    
       declare @sql nvarchar(max)
       set @sql = N'
           select ColumnList, [PLACEHOLDER]
           from TableA
           pivot 
           (
              min(Value)
              for Key in ([PLACEHOLDER])
           ) a'
       set @sql = REPLACE(@sql, '[PLACEHOLDER]', @PivotedList)
       print @sql
       exec sp_executesql @sql
    

    There is a good reference for concatenating many rows into a single text string. You will probably need it for @PivotedList parameter.

    I hope I am not entirely of the mark 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

If I have a function that produces a result int and a result string
I have a need for a high-performance string hashing function in python that produces
I have a function that is being called from different threads in the application.
I have a function that allows users to edit a row in a table
I have a function that is recursively calling itself, and i want to detect
I have a function that pulls rows from a database, the content->id and content->type
I have a function that outputs an XML string: <expensesAC> <cashflow> <month>6</month> <cash>300</cash> <projected>null</projected>
I want to have a SelectAll function which takes in a few arguments (class,
Say I have a date function that produces the output: 2011-10-03 PHP: $todayDt =
I have a function that takes a couple of font parameters, and produces the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.