How do you import a large MS SQL .sql file?

前端 未结 11 1448
心在旅途
心在旅途 2020-11-28 00:20

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

11条回答
  •  我在风中等你
    2020-11-28 01:02

    From the command prompt, start up sqlcmd:

    sqlcmd -S  -i C:\.sql 
    

    Just replace with the location of your SQL box and with the name of your script. Don't forget, if you're using a SQL instance the syntax is:

    sqlcmd -S \instance.
    

    Here 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] 
    

提交回复
热议问题