gpt4 book ai didi

c# - 自动执行通过c#打开的SSMS .exe

转载 作者:太空宇宙 更新时间:2023-11-03 23:42:47 25 4
gpt4 key购买 nike

我使用此代码通过 C# 从文件夹中打开 ssms。

private void button1_Click(object sender, EventArgs e)
{
System.Diagnostics.Process.Start("ssms.exe", @"-S server-name -d db_name -E F:\\sql_files\Batch1.sql ");

}

现在我想自动执行已打开的 ssms,这样用户就不必按“执行”按钮或 F5

谢谢。

最佳答案

正在运行 ssms/?在命令行中,似乎没有选项可以执行您想要的操作。您需要使用上面发布的 sqlcmd。

用法:ssms.exe [-S server_name[\instance_name]] [-d database] [-U user] [-P password] [-E] [file_name[, file_name]] [/?]

[-S The name of the SQL Server instance to which to connect]
[-d The name of the SQL Server database to which to connect]
[-E] Use Windows Authentication to login to SQL Server
[-U The name of the SQL Server login with which to connect]
[-P The password associated with the login]
[file_name[, file_name]] names of files to load
[-nosplash] Supress splash screen
[/?] Displays this usage information

关于c# - 自动执行通过c#打开的SSMS .exe,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28468827/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com