SQL, how t write correctly a query on cicode

Hello,

I received from database manager the request to create this query to cicode to copy data between twp SQL table on the same Database. I cannot find the correct way to write it on cicode,  and other problem, Citect respond me that query is too long.. Someone can help me?

INSERT INTO [_PIZZA_PARAMETRI_RICETTE_HISTORY]

      (PPR_MAC_NUM
      ,PPR_NUMERO_ORDINE
      ,PPR_DATETIME
      ,PPR_RICETTA
      ,PPR_PARAMETRO
      ,PPR_VALORE_A
      ,PPR_VALORE_N)
SELECT
      PPR_MAC_NUM
      ,PPR_NUMERO_ORDINE
      ,PPR_DATETIME
      ,PPR_RICETTA
      ,PPR_PARAMETRO
      ,PPR_VALORE_A
      ,PPR_VALORE_N
  FROM [dbo].[_PIZZA_PARAMETRI_RICETTE]
  WHERE  PPR_MAC_NUM = 1

Thank you

Parents
  • Good to see you resolved it. However you really should be identifying exactly what columns you're inserting values into, otherwise if the table design ever changes (columns added, columns rearranged) your query may no longer work; it's also a good idea for future you or other people looking at the code to be able to easily identify the columns and the data you're writing into the table.

    E. G. Syntax:
    INSERT INTO table
    (col1, col2,...., colX)
    VALUES (col1val, col2val,..., colXval)

    Edit: I edited the sentence as I was clearly lacking sleep...

Reply
  • Good to see you resolved it. However you really should be identifying exactly what columns you're inserting values into, otherwise if the table design ever changes (columns added, columns rearranged) your query may no longer work; it's also a good idea for future you or other people looking at the code to be able to easily identify the columns and the data you're writing into the table.

    E. G. Syntax:
    INSERT INTO table
    (col1, col2,...., colX)
    VALUES (col1val, col2val,..., colXval)

    Edit: I edited the sentence as I was clearly lacking sleep...

Children
No Data