开发者

SSMS 2008 Add-In - Execute Query

开发者 https://www.devze.com 2022-12-23 16:17 出处:网络
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.Scr

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开发者_如何学Go


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

0

精彩评论

暂无评论...
验证码 换一张
取 消