xo / usql

Universal command-line interface for SQL databases
MIT License
8.96k stars 350 forks source link

copy to MS SQLSERVER (set SET IDENTITY_INSERT ON) #323

Closed michaelcplusplus closed 2 years ago

michaelcplusplus commented 2 years ago

I want to copy data to a MS SQLSERVER database table with an identity column. For this I would have to issue this command before the copy action: SET IDENTITY_INSERT

ON

Is there a way to do this?

Best regards Michael

kenshaw commented 2 years ago

Not at this time, no. If you need to do this with SQL Server, I'd suggest turning off column integrity temporarily, then turning it back on after a \copy command. Because its not possible to support all the different databases, I do not see this as being made into an option specifically (and only) for SQL Server. If you'd like to submit a PR with logic that provides some kind of additional functionality/logic for this, we're always open to it!