Share via

how to keep sql format using variable

MikeY1975 41 Reputation points
Nov 30, 2021, 8:31 PM

When storing a SQL statement in a variable how do you keep the format? When I copy and paste the SSIS variable value into SSMS to edit it, it doesn't keep the original format i.e. retaining the carriage returns.

SQL Server Integration Services
SQL Server Integration Services
A Microsoft platform for building enterprise-level data integration and data transformations solutions.
2,616 questions
0 comments No comments
{count} votes

Accepted answer
  1. ZoeHui-MSFT 38,791 Reputation points
    Dec 1, 2021, 1:59 AM

    Hi @MikeY1975 ,

    Do you mean that you add the value the variable like below code,

    INSERT INTO table_A  
    VALUES ('1', '2', '3')  
    

    And then when you copy the code to SSMS, it becomes like INSERT INTO table_A VALUES ('1', '2', '3')?

    If yes, I think it's hard to keep the format with the carriage returns.

    When you add the sql statement in the value, the format has already changed so we could not keep the sql format.

    You may save the sql statement to the local file before adding to the variables and then you may edit it in SSMS with the correct format.

    If I misunderstand your need, please incorrect me.

    Regards,

    Zoe


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


1 additional answer

Sort by: Most helpful
  1. Olaf Helper 45,371 Reputation points
    Dec 1, 2021, 7:18 AM

    That's to less on informations.
    How do you "store" (assign) a SQL Statement to a variable and why does the format matters in any way?

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.