Sub ExcelADOSQLServer()
Dim Cn As ADODB.Connection
Dim Server_Name As String
Dim Database_Name As String
Dim User_ID As String
Dim Password As String
Dim SQLStr As String
Dim rs As ADODB.Recordset
Set rs = New ADODB.Recordset
SQLStr = "SELECT top 100 * FROM [GLDATA]" ' Enter your SQL here
Set Cn = New ADODB.Connection
Cn.Open "Driver={SQL Server};Server=JDEDBPC01\SQL1; Database=budget; UID=budget; PWD=M3dak$AP"
rs.Open SQLStr, Cn, adOpenStatic
Dim NewRecord As Range
ThisWorkbook.Sheets("Sheet1").Range("B2").CopyFromRecordset rs
rs.Close
Set rs = Nothing
Cn.Close
Set Cn = Nothing
End Sub
Dim Cn As ADODB.Connection
Dim Server_Name As String
Dim Database_Name As String
Dim User_ID As String
Dim Password As String
Dim SQLStr As String
Dim rs As ADODB.Recordset
Set rs = New ADODB.Recordset
SQLStr = "SELECT top 100 * FROM [GLDATA]" ' Enter your SQL here
Set Cn = New ADODB.Connection
Cn.Open "Driver={SQL Server};Server=JDEDBPC01\SQL1; Database=budget; UID=budget; PWD=M3dak$AP"
rs.Open SQLStr, Cn, adOpenStatic
Dim NewRecord As Range
ThisWorkbook.Sheets("Sheet1").Range("B2").CopyFromRecordset rs
rs.Close
Set rs = Nothing
Cn.Close
Set Cn = Nothing
End Sub