Check whether the database already exists during installation

Source: Internet
Author: User

Create ServerProgramTo create a database and tables. Before creating a database, check whether the database already exists. If yes, a pop-up dialog box is displayed asking if you want to overwrite the existing database data. Here is a usageNSIsHow to check the installation package.


NSI of the detection partCodeAs follows:

Nsexec ::Exec 'Sqlcmd-S. \ sqlexpress-D sampledb'

Pop $0

Intcmp $0 1Update ask


The principle is very simple.SqlcmdLog on to the database you want to create. If the database already exists, log on successfully,$0The value in will be0Otherwise1.

NSIsThere are manyExecAnd there are many ways to detect databases. I tried many methods today, some of which are not feasible and some are too complicated. The above method is relatively simple. I hope to give some tips to those who need it.


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: 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.