0 votes
1 view
in SQL by (20.3k points)

I use RedGate SQL data compare and generated a .sql file, so I could run it on my local machine. But the problem is that the file is over 300mb, which means I can't do copy and paste because the clipboard won't be able to handle it, and when I try to open the file in SQL Server Management Studio I get an error about the file being too large.

Is there a way to run a large .sql file? The file basically contains data for two new tables.

1 Answer

0 votes
by (40.3k points)

 Start up sqlcmd, from the command prompt in this way:

sqlcmd -S <server> -i C:\<your file here>.sql 

You can just replace the <server> with the location of your SQL box and <your file here> with the name of your script. 

If you're using a SQL instance then use the syntax as follows:

sqlcmd -S <server>\instance.

Following is the list of all arguments you can pass sqlcmd:

Sqlcmd            [-U login id]          [-P password]

  [-S server]            [-H hostname]          [-E trusted connection]

  [-d use database name] [-l login timeout]     [-t query timeout] 

  [-h headers]           [-s colseparator]      [-w screen width]

  [-a packetsize]        [-e echo input]        [-I Enable Quoted Identifiers]

  [-c cmdend]            [-L[c] list servers[clean output]]

  [-q "cmdline query"]   [-Q "cmdline query" and exit] 

  [-m errorlevel]        [-V severitylevel]     [-W remove trailing spaces]

  [-u unicode output]    [-r[0|1] msgs to stderr]

  [-i inputfile]         [-o outputfile]        [-z new password]

  [-f  | i:[,o:]] [-Z new password and exit] 

  [-k[1|2] remove[replace] control characters]

  [-y variable length type display width]

  [-Y fixed length type display width]

  [-p[1] print statistics[colon format]]

  [-R use client regional setting]

  [-b On error batch abort]

  [-v var = "value"...]  [-A dedicated admin connection]

  [-X[1] disable commands, startup script, environment variables [and exit]]

  [-x disable variable substitution]

  [-? show syntax summary]

Related questions

+2 votes
1 answer
0 votes
1 answer
asked Jul 11, 2019 in SQL by Tech4ever (20.3k points)
0 votes
1 answer
0 votes
1 answer
asked Oct 20 in SQL by dev_sk2311 (14.3k points)
Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...