Skip to Content
author's profile photo Former Member
Former Member

Dynamic select inside storedprocedure

Hi All,

I have a requirement to generate the dynamic select statement . Procedure will accept the table name and schema name as parameters and return the select statement.

I could able to get the column names from sys.columns table. How to loop through the rows and concatenate the column values into single string?

Regards,

Suman.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

3 Answers

  • Best Answer
    Posted on Feb 14, 2014 at 09:53 AM

    Hi Suman,

    Have a look on the below document:

    SAP HANA: Generic Procedure using Arrays to Load delta data into Tables

    Regards,

    Krishna Tangudu

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Feb 13, 2014 at 09:34 PM

    Hi there, take a look a the syntax for the procedure shown in How to avoid NULL (?) values when using dimension attributes with fact table columns that contain blanks ( '' ), this should help you along with a similar requirement.

    Regards,

    Justin

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Feb 11, 2014 at 11:22 AM

    Hi Suman,

    I guess you are working on replicating procedure, if am not wrong.

    You can use a cursor to achieve it. You can open a cursor to read the columns even from a table TABLE_COLUMNS and then loop and concatenate them into a single string to form you insert or update query.

    Regards,

    Krishna Tangudu

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.