denisenkom / go-mssqldb

Microsoft SQL server driver written in go language
BSD 3-Clause "New" or "Revised" License
1.82k stars 500 forks source link

insert or update at same time using bulk insert (CopyIn) #611

Closed usermsdpa closed 4 years ago

usermsdpa commented 4 years ago

Hi i am using CopyIn to bulk inesrt data into sql server DB. is there a way i can either insert or update based on the records available in the DB at the same time, as i have a service picks runs a picks data every 2 min from an api which should be either inserted or updated to DB.

kardianos commented 4 years ago

No.

For this you should create a temp table or staging table, and once inserted, perform an action on it.

This is a limitation of SQL Server.

usermsdpa commented 4 years ago

Can you please point to an example or code snippet. Sorry new to Go

usermsdpa commented 4 years ago

Can you please share an example for this. sorry i am new to go. i tried but cant get it to work

On Sun, Oct 4, 2020 at 8:28 AM Daniel Theophanes notifications@github.com wrote:

No.

For this you should create a temp table or staging table, and once inserted, perform an action on it.

This is a limitation of SQL Server.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/denisenkom/go-mssqldb/issues/611#issuecomment-703248458, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACUQB6XBUWPYUIXI5WLXFZ3SJBS7TANCNFSM4SDN3SEQ .

-- Thanks and Regards Shravya Muppidi