Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Maximum size of .SQL file or variable for SQL server?

I have a SQL file/SQL string which is about 20MB. SQL server simply cannot accept this file. Is there a limit on the maximum size of the .SQL file or variable which is used to query or insert data into SQL server ?

When I say variable, it means passing a variable to SQL server through some programming language or even ETL tool.

like image 860
Steam Avatar asked Nov 17 '13 08:11

Steam


People also ask

How do I run a very large .SQL file?

To execute a large script:On the Database menu, click Execute Large Script. In Connection, select a connection to a required database server against which you want to execute your script. In Database, select a required database from the drop-down list. In File name, specify the path to the script you want to execute.

Is there a limit to size of SQL query?

The limit is based on the size of internal structures generated for the parsed SQL statement. The limit is 32766 if CQE processed the select statement.

What is the max length of varchar variable in SQL Server?

Values in VARCHAR columns are variable-length strings. The length can be specified as a value from 0 to 65,535. The effective maximum length of a VARCHAR is subject to the maximum row size (65,535 bytes, which is shared among all columns) and the character set used.


1 Answers

You can use SQLCMD, but I just ran into a 2GB file size limit using that command-line tool. This was even though I had a GO after every statement. I get an Incorrect syntax error once the 2GB boundary is crossed.

After some searching, I found this link: https://connect.microsoft.com/SQLServer/feedback/details/272757/sqlcmd-exe-should-not-have-a-limit-to-the-size-of-file-it-will-process

The linked page above says that every character after 2GB is ignored. That could explain my Incorrect syntax error.

like image 87
DarkTygur Avatar answered Sep 25 '22 01:09

DarkTygur