Quantcast
Channel: SQLServerCentral » SQL Server 2014 » Development - SQL Server 2014 » Latest topics
Viewing all articles
Browse latest Browse all 3145

Needing some help - Moving data from one table to multiple

$
0
0
Hoping someone can point me in the right direction, we use a database to log alarms and trend data. We are working with a client that want's all of there old data imported. Normally I have an excel spread sheet that generates the code similar to below. However the client gave me a huge database that I got the tables moved over into ours but I can't figure out how to move it from there into our multiple tables. Normally I run 3 sets of code, one for each table.So basically I need to pull data from dbo.old_data and check if it exist by index of case_01, if not copy the data from various columns to three different tables. If it does exist update it, they are still collecting data so I will have to do this again but with less data.Thank you in advance for your help, I'm a plc programmer so sorry for not knowing the proper terms.[code="sql"]if not exists(select * from EPA001 where rtrim(CASE_01) = '000001') insert into EPA001([CASE_01], [CLASS], [SUBCLASS]) select '000001', 'FLR_01', 'CRUDE'else update EPA001 set CLASS='FLR_01', SUBCLASS='CRUDE'[/code]

Viewing all articles
Browse latest Browse all 3145

Latest Images

Trending Articles



Latest Images