Hola,
Posiblemente, ejecuta la instrucción SQL que está en la celda seleccionada (ActiveCell), en la instancia de SQL Server y la base de datos especificada en la conexión. (Necesitas agregar la referencia a "Microsoft ActiveX Data Objects 2.8 Library" en Herramientas->Referencias).
Código vb:
Ver originalOption Explicit
Private Sub ExecuteSQL_CurrentRow()
Dim conConnection As ADODB.Connection
Dim cmdExecute As ADODB.Command
Dim strSQL As String
strSQL = Application.ActiveCell.Value
If Trim(strSQL) = "" Then Exit Sub
On Error GoTo eHand
Set conConnection = New ADODB.Connection
Set cmdExecute = New ADODB.Command
conConnection.ConnectionString = _
"Provider=SQLOLEDB.1;" & _
"Password=MyPassword;" & _
"Persist Security Info=True;" & _
"User ID=sa;" & _
"Initial Catalog=MyDatabase;" & _
"Data Source=MYSERVER\MYSQLEXPRESS"
conConnection.Open
cmdExecute.ActiveConnection = conConnection
cmdExecute.CommandText = strSQL
cmdExecute.CommandTimeout = 120
cmdExecute.CommandType = adCmdText
cmdExecute.Execute
Exit Sub
eHand:
MsgBox "No se pudo completar la operación." & vbCrLf & _
Err.Description, vbExclamation + vbOKOnly, "Error"
End Sub
Saludos,