SQLCommand ExecuteNonQuery Maximum CommandText Length?

I searched on the Internet and everything seems to be about individual fields or one insert. I have a migration tool that migrates from an old old database (superbase) to our SQL Server database (2008). I am currently reading 20,000 records from an old database and generating one large line SQLCommand.CommandTextwith 20,000 insert instructions, separated by semicolons. This works great . But can I do 25k? 30k? I tried to have no restrictions, but when I tried to run ExecuteNonQuerywithCommandTextcontaining over 4 million INSERT instructions, he said something about being too long. I don’t remember the exact error message, sorry. I can not find the exact restriction documentation. It’s important for me to find out, because the more investments I can shoot at a time, the faster the whole process. Any tips / links / documentation would be appreciated, thanks!

+4
source share
2 answers

It depends on the version of SQL Server.

http://technet.microsoft.com/en-us/library/ms143432.aspx

For SQL Server 2012, the batch size or SQL query (String) = 65,536 * The size of the network packet.

- (TDS), . 4 .

, 64K x 4K = 256 . , , .

+4

Source: https://habr.com/ru/post/1523956/


All Articles