Installing a new instance of SQL Server at the command prompt enables you to specify the features to install and how they should be configured. You can also specify silent, basic, or full interaction with the setup of the user interface. Here, I am using the "silent" type of interaction.
When you install SQL Server at the command prompt, specify the setup parameters for your installation at the command prompt as part of your installation syntax.
Now, call the SqlExpInstall class to install the SQL Server.
- using System;
- using System.IO;
- using System.Diagnostics;
- using System.Windows.Forms;
-
- namespace SqlExp
- {
- static class Program
- {
-
-
-
- [STAThread]
- static void Main()
- {
- InstallSqlEngine()
- }
-
- private static void InstallSqlEngine()
- {
- SqlExpInstall EI = new SqlExpInstall();
- EI.sqlExpressSetupFileLocation = Path.Combine(@"C:\Downloads", "sqlexpr.exe");
- int pid = EI.InstallExpress();
-
-
- Process installp = Process.GetProcessById(pid);
- if (installp != null)
- installp.WaitForExit();
- int cc = installp.ExitCode;
- }
- }
- }
I hope this is useful to all the readers. Happy Coding!
Reference - https://social.technet.microsoft.com/wiki/contents/articles/940.how-to-embed-sql-server-express-in-an-application.aspx