How to execute large SQL files on SQL Server?

I have about 50 T-SQL files, some of them 30 MB, but some of them 700 MB. I thought they were executed manually, but if the file is larger than 10 MB, it throws an exception in memory in SQL Server Management Studio.

Any ideas?

+3
source share
3 answers

If you have so much data, isnโ€™t it much easier and smarter to have this data, for example. CSV file and then bulk import this data into SQL Server?

Check out the BULK INSERT team - allowing you to quickly and efficiently load large amounts of data into SQL Server - much better than such a huge SQL file!

The command looks something like this:

BULK INSERT dbo.YourTableName
   FROM 'yourfilename.csv'
   WITH ( FIELDTERMINATOR =';',
          ROWTERMINATOR =' |\n' )

, .

+5

sqlcmd, . http://msdn.microsoft.com/en-us/library/ms162773.aspx

:

sqlcmd -U userName -P myPassword -S MYPCNAME\SQLEXPRESS -i myCommands.tsql
+12

, , ... SqlCommand.ExecuteNonQuery() ? .

:

  • ( )
  • ( )
+3

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


All Articles