x

duplicate row need to insert for the table

I want to insert a duplicate rows in a table. I want to insert a new row in a table that should have same values as of the previous row and in addition to that, i will be keeping the one column value in that row. I am getting the final result like below

PO_ID   PONO  ORDERDATE    SUPPLIERNO POCLOSED    DivisionNo SupplierName    CUSTOMER   Customer Name JobNo   ITEMNUMBER    RECEIPTNO  RECEIPTDATE  ORDEREDAMT   RECEIVEDAMT   INVOICEDAMT   INVOICENO INVOICEDATE TAX
423105  E1230-202783     4/29/2011    NOC370  0  1230 NULL    NULL   NULL  NULL ALARM MONITORING    240021 1/12/2012   646.8 80.85   80.85 1012012 1/1/2012    10.51
442320  E1230-202830     6/7/2011 2001632 0   1230  NULL NULL    NULL   NULL  DOC-SHREDDING    239561 1/11/2012   840   70    70 172861  12/30/2011   9.1
442320  E1230-202830     6/7/2011 2001632 0   1230  NULL NULL    NULL   NULL  DOC-SHREDDING    251960 2/27/2012   840   70    70 179866  2/17/2012    9.1
491968  E1230-202920     9/15/2011    108391 0   1230  NULL NULL    NULL   NULL  227334   257771    3/21/2012  440.48   110.12    110.12 4173629 3/11/2012   46.54
491968  E1230-202920     9/15/2011    108391 0   1230  NULL NULL    NULL   NULL  227335   257771    3/21/2012  991.52   247.88    247.88 4173629 3/11/2012   46.54
493980  E1230-202925     9/20/2011    2000270    0  1230 NULL    NULL   NULL  NULL H WATERCOOLER   239606    1/11/2012  395.4    32.95  32.95    32112496   1/1/2012  4.28
493980  E1230-202925     9/20/2011    2000270    0  1230 NULL    NULL   NULL  NULL H WATERCOOLER   249084    2/16/2012  395.4    32.95  32.95    32113163   2/1/2012  4.28
536638  E1230-203024     12/7/2011    2000960    0  1230 NULL    NULL   NULL  NULL HAM. PREMISE CLEANING   244725    1/31/2012  6500 1300    1300   219467    1/27/2012  169
536638  E1230-203024     12/7/2011    2000960    0  1230 NULL    NULL   NULL  NULL HAM. PREMISE CLEANING   253587    3/5/2012   6500  1300 1300    219472 2/25/2012   169
537559  E1230-203027     12/9/2011    2000558    1  1230 NULL    NULL   NULL  NULL BL. LOGO BALL CAPS  238140   1/4/2012  650  650  650  16361    12/20/2011 86.91
541309  E1230-203042     12/16/2011   2009825   1 1230    NULL   NULL  NULL NULL    HDYEDDIESEL    238150 1/4/2012    731.264    731.264    731.264    264933 12/12/2011  99.16
542546  E1230-203045     12/20/2011   2000558   1 1230    NULL   NULL  NULL NULL    CAMO HATS W/LOGO   238428    1/5/2012   550   550   550   16394 1/20/2012   73.06
543221  E1230-203048     12/21/2011   105404    1  1230 NULL    NULL   NULL  NULL A419697 238143  1/4/2012 109.52  109.52   109.52    4609717    12/21/2011 136.62
543221  E1230-203048     12/21/2011   105404    1  1230 NULL    NULL   NULL  NULL BB92303 238143  1/4/2012 12  12   12    4609717    12/21/2011 136.62
543221  E1230-203048     12/21/2011   105404    1  1230 NULL    NULL   NULL  NULL GS378A-L    238143 1/4/2012    357.6  357.6    357.6  4609717  12/21/2011   136.62
543221  E1230-203048     12/21/2011   105404    1  1230 NULL    NULL   NULL  NULL GS378A-XL   238143    1/4/2012   143.04    143.04 143.04  4609717  12/21/2011   136.62
543221  E1230-203048     12/21/2011   105404    1  1230 NULL    NULL   NULL  NULL GS66Q   238143    1/4/2012   321.6 321.6   321.6 4609717 12/21/2011  136.62
543221  E1230-203048     12/21/2011   105404    1  1230 NULL    NULL   NULL  NULL H06A    238143 1/4/2012    46.2   46.2  46.2 4609717 12/21/2011  136.62
543221  E1230-203048     12/21/2011   105404    1  1230 NULL    NULL   NULL  NULL P73 238143  1/4/2012 61  61   61    4609717    12/21/2011 136.62

The above result is my output, now for that result i need to add Tax column value as a seperate entry and rest of the columns should be blank and the duplicate entry should insert for every PO and for for every InvoiceNo

more ▼

asked Mar 30, 2012 at 01:03 PM in Default

Mohan gravatar image

Mohan
324 37 55 60

(comments are locked)
10|1200 characters needed characters left

1 answer: sort newest
I think you would be better off with a separate table for the payment history and create a view to display your final results by joining the two tables rather than trying to jam it all in one table.
more ▼

answered Mar 30, 2012 at 02:11 PM

Blackhawk-17 gravatar image

Blackhawk-17
11.9k 28 31 36

(comments are locked)
10|1200 characters needed characters left
Your answer
toggle preview:

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

New code box

There's a new way to format code on the site - the red speech bubble logo will automatically format T-SQL for you. The original code box is still there for XML, etc. More details here.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

SQL Server Central

Need long-form SQL discussion? SQLserverCentral.com is the place.

Topics:

x985

asked: Mar 30, 2012 at 01:03 PM

Seen: 413 times

Last Updated: Mar 30, 2012 at 02:11 PM