skip to Main Content

I need remove the all comments in a SQL view created in Azure SQL Data Warehouse.

Create the query without comments (/* */ ; — , …); regular expression functions not working

Query:

CREATE VIEW [dimension].[v_dim_customer] 
AS
    SELECT
        -- primary key
        KNA1.fk_MANDT_KUNNR AS sk_customer, 
        -- attributes
        KNA1.[NAME1_nom], 
        --  KNA1.[DEAR1_concurrents], 
        -- KNA1.[DEAR2_responsable_adv], 
        ----- /*flag client interne/externe*/-----
        flag_ext_int.externe_interne_code, 
        /* flag client interne/externe niveau 2 (détaillé : intra groupe / intra société / externe)*/
        flag_ext_int.externe_interne_level_2_code, 
        --   date pour delta
        -- CY.max_slt_datetime
        -- add --18/12/2023
    FROM 
        [e3p].[KNA1] KNA1
    LEFT OUTER JOIN 
        [e3p].T005T T005T ON KNA1.[fk_MANDT_LAND1] = T005T.[fk_MANDT_LAND1]
                          AND T005T.[bk_SPRAS_code_langue] = N'F' -- français
     LEFT OUTER JOIN 
         [e3p].T016T ON KNA1.[fk_MANDT_BRSCH] = T016T.[fk_MANDT_BRSCH]
                     
     -- AND KNA1.[SPRAS_code_langue] = T016T.[bk_SPRAS_code_langue]
                     AND T016T.[bk_SPRAS_code_langue] = N'F' -- français
     -- modif ska 03/12 : ajout  delai moyen de paiement, credit autorisé et recommendé
     -- LEFT OUTER JOIN [e3p].[v_KNKK_fr_compute] as KNKK ON KNA1.bk_MANDT_mandant = KNKK.bk_MANDT_mandant
     -- AND KNA1.bk_KUNNR_client = KNKK.bk_KUNNR_client

2

Answers


  1. CREATE VIEW [dimension].[v_dim_customer] AS 
    SELECT
         -- primary key
         KNA1.fk_MANDT_KUNNR AS sk_customer, 
         -- attribut 
         KNA1.[NAME1_nom], 
         flag_ext_int.externe_interne_code, 
         /* flag client interne/externe niveau 2 (détaillé : intra groupe / intra société / externe)*/
         flag_ext_int.externe_interne_level_2_code
         FROM [e3p].[KNA1] KNA1
         LEFT OUTER JOIN [e3p].T005T T005T 
         ON KNA1.[fk_MANDT_LAND1] = T005T.[fk_MANDT_LAND1]
         AND T005T.[bk_SPRAS_code_langue] = N'F' -- français
         LEFT OUTER JOIN [e3p].T016T  
         ON KNA1.[fk_MANDT_BRSCH] = T016T.[fk_MANDT_BRSCH]
         AND T016T.[bk_SPRAS_code_langue] = N'F' -- français
    

    try this, i think that may works

    Login or Signup to reply.
  2. You have several options available to you:

    1. Remove them manually. Definitely not fast or fun, but gets the job done! 😀
    2. Copy/paste the script into a text editor (eg. Visual Studio Code, Azure Data Studio), remove the comments using the text editor’s regex features, then copy/paste the cleaned script into Azure SQL DW/Azure Synapse.
    3. Similar to option 2, connect to Azure SQL DW/Azure Synapse in Azure Data Studio and directly modify your scripts in there. You’ll benefit from improved text editing and management tools, and extensions available in Azure Data Studio.

    My preference is option 3 because it lets you modify, test, and deploy the script all in one well-outfitted tool.
    You’re stuck with option 1 and 2 if you don’t have admin access to install the text editors listed above on your local machine.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search