This article is a mirror article of machine translation, please click here to jump to the original article.

View: 3486|Reply: 2

[Source] (MSSQL) SQL SERVER executes very large SQL scripts

[Copy link]
Posted on 6/1/2023 6:55:13 PM | | | |
Requirements: Export the structure of a table and import the data from one server to another server.The .sql files exported from the source database are very large and take up more than 1GIf you use SSMS to run a new query, it will not open normally, and the program will freeze, how to run a very large SQL script?

You can execute the .sql script file using the SQLCMD tool with the following parameters:

sqlcmd
   -a packet_size
   -A (dedicated administrator connection)
   -b (terminate batch job if there is an error)
   -c batch_terminator
   -C (trust the server certificate)
   -d db_name
   -D
   -e (echo input)
   -E (use trusted connection)
   -f codepage | i:codepage[,o:codepage] | o:codepage[,i:codepage]
   -g (enable column encryption)
   -G (use Azure Active Directory for authentication)
   -h rows_per_header
   -H workstation_name
   -i input_file
   -I (enable quoted identifiers)
   -j (Print raw error messages)
   -k[1 | 2] (remove or replace control characters)
   -K application_intent
   -l login_timeout
   -L[c] (list servers, optional clean output)
   -m error_level
   -M multisubnet_failover
   -N (encrypt connection)
   -o output_file
   -p[1] (print statistics, optional colon format)
   -P password
   -q "cmdline query"
   -Q "cmdline query" (and exit)
   -r[0 | 1] (msgs to stderr)
   -R (use client regional settings)
   -s col_separator
   -S [protocol:]server[instance_name][,port]
   -t query_timeout
   -u (unicode output file)
   -U login_id
   -v var = "value"
   -V error_severity_level
   -w screen_width
   -W (remove trailing spaces)
   -x (disable variable substitution)
   -X[1] (disable commands, startup script, environment variables, optional exit)
   -y variable_length_type_display_width
   -Y fixed_length_type_display_width
   -z new_password
   -Z new_password (and exit)
   -? (usage)


Run the sqlcmd command as follows:



go-sqlcmd utility

Using the go-sqlcmd utility (preview), you can enter Transact-SQL statements, system procedures, and script files at the command prompt and use the go-mssqldb driver for the Go language. go-sqlcmd is designed to port sqlcmd to the Go language in its entirety and compile it into executable binaries for x64 and arm64 architectures for Windows, macOS, and Linux. Download and install the go-sqlcmd binary to get started without additional dependencies. Using go-sqlcmd instead of sqlcmd removes ODBC driver dependencies, adds options for Azure Active Directory authentication types, and adds other enhancements.

Reference:

The hyperlink login is visible.
The hyperlink login is visible.





Previous:VMware (VM) Virtual Machine Linked Clone and Full Clone Difference
Next:The .NET Core library reads versions and embedded resources
 Landlord| Posted on 6/1/2023 6:55:43 PM |
SQL Server inserts 10,000 pieces of data in a loop
Create a Users table and insert 10,000 pieces of data, the script is as follows:

 Landlord| Posted on 6/1/2023 7:00:55 PM |
sqlcmd output incomplete solution
https://www.itsvse.com/thread-9125-1-1.html
Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com