I have a few tables, in one of them I am loading with the Excel file and then I put in the selection from the target I have the column id
in the table, which does not have IDENTITY
and I can not create it, so I select ROW_NUMBER ()
for my selection. I used the INSERT
, but now I am having problems, the next time I am loading the file into my temporary table from which I INSERT
Selection data for is started from 1 and if IAM is trying to get involved then I am getting error problems with primary key / hence the ID needs to be added on ID basis, which is already targeted For example, if the previous record in the target table is in the record ID before the new record 1001
Enter in Table 1 (ID, OKIID, OPPID, Okide ED,) SELECT - RO (Table Choose from 1 MAX (ID) AS 'table Last ID', ROW_NUMBER (by) over (order (SELECT 0)), - ID - Int A. [ID] AS OKaid, - Int c. [ID] AS Okaid, - Int D. [ID] AS OAKID, - Int Ephram [DBO]. # Table B LEFT Outer Table 2 AO BF 6 = A. [National Symbolbo] Add bonus to left over table 3c F 4 = C. Include coded left outer contact in Table4D on b.F5 = D. Coded left over 1 table on 1F on BF1 = F. Code where FCode is faucet
Anyone Consider how to continue to insert ID in order? I can not use identity
on this table. I hope you can understand my explanation
Enter in Table 1 (id, OKEID, OPDID, OKAIDID) - Select from table 1, MAX (ID) AS 'Last ID in table', a.last_id + ROW_NUMBER () over (line by SELECT 0)), - id - int one. [ID] AS Okeid, - OKEID - At C. [ID] AS O.P.D.D., - OBCDID - IT D. [ID] AS OKDID - OKWID ID - Int FDR [DBO]. # Table B LEFT OTier Table 2 AOBFF 6 = A. [NationalSombol] Left Open Connect Table 3C On BF4 = C Codes Connect Over Left Connect Table 4D On BF 5 = D. Coded Left Outer B1F on BF1 = F. Cold Cross Join (id) as the frame table from last_i D 1) A WHERE f.code is faucet
and some Test:
Create Table # A (An Integrated Key, AAA) Create Table # B (BIT) in # values (1,1); INSERT #b values (1); Insert #b values (2); Insert in #b values (3); #b Include values (4); INSERT #b values (5); INSERT #A SELECT last_id + ROW_NUMBER () over (ORDER BY bb), #bb cross join from BB (SELECT MAX (a) last_id FROM #a) a
No comments:
Post a Comment