SSMS 2008 Add-In - Execute Query
I'm loading a sql script up to an SSMS 2008 add-in like so:
' create a new blank document
ServiceCache.ScriptFactory.CreateNewBlankScript(Microsoft.SqlServer.Management.UI.VSIntegration.Editors.ScriptType.Sql)
' insert SQL statement to the blank document
Dim doc As EnvDTE.TextDocument = CType(ServiceCache.ExtensibilityModel.Application.ActiveDocument.Object(Nothing), EnvDTE.TextDocument)
doc.EndPoint.CreateEditPoint().Insert(_Output.ToString())
Is there a way to automatically execute the statement as well?
Thanks,
Mark开发者_如何学GoIn SSMS 2008 R2 it would look like this:
doc.DTE.ExecuteCommand("Query.Execute");
I looked around he object model and could not find the 'execute' method - but there must a way of doing this...
But thinking slightly outside the box, you could do this.
// Set the active document
doc.DTE.ActiveDocument.Activate();
// Press F5 - which calls Execute.
SendKeys.Send("{F5}");
Okay, its a hack, but it might get you over the problem for now. :-)
精彩评论