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

C# 自动执行通过c打开的SSMS.exe#,c#,sql,sql-server-2008,C#,Sql,Sql Server 2008,我使用此代码通过c#从文件夹打开SSM 现在我想自动执行已打开的SSM,这样用户就不必按“执行”按钮或F5 谢谢。正如GB所说,您似乎想要的是使用SQLCMD。请参阅下面的链接: 运行ssms/?在命令行中,似乎没有执行所需操作的选项。您需要使用sqlcmd,因为他们已经在上面发布了 用法: ssms.exe[-S服务器\U名称[\instance\U名称][-d数据库][-U用户][-P密码][E][file\U名称[,file\U名称]][/?] [-S The name of the SQ

我使用此代码通过c#从文件夹打开SSM

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


谢谢。

正如GB所说,您似乎想要的是使用SQLCMD。请参阅下面的链接:


运行ssms/?在命令行中,似乎没有执行所需操作的选项。您需要使用sqlcmd,因为他们已经在上面发布了

用法: ssms.exe[-S服务器\U名称[\instance\U名称][-d数据库][-U用户][-P密码][E][file\U名称[,file\U名称]][/?]

[-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

显然,我没有您正在处理的特定场景的上下文,也没有您希望用户对输出执行的操作,但是您是否考虑过只使用SQLCMD并选择性地将输出发送到文件?是的,如果您将ssms.exe替换为SQLCMD.exe,它可能会执行您想要的操作!另见:
[-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