title: Retrieve/create recordset from SQL Server data in Excel vba
body: <p>I want to access / retrieve / create recordset from SQL Server in Excel vba.</p>
  
  <p>I tried following methods but they return an error.</p>
  
  <p>Code 1:</p>
  
  <pre><code>Dim conn As ADODB.Connection
  Dim rs As ADODB.Recordset
  Dim sConnString As String
  
  sConnString = "Provider=sqloledb; Server=192.168.0.204; Database=REPORTdb2"
  Set Conn = New ADODB.Connection
  Set rs = New ADODB.Recordset
  conn.Open sConnString 
  Set rs = conn.Execute("select * from Table1;")
  </code></pre>
  
  <p>at the line <code>conn.Open sConnString</code> an error occurs:</p>
  
  <blockquote>
    <p>Invalid authorization specification</p>
  </blockquote>
  
  <p>Code2:</p>
  
  <pre><code>sConnString = "Provider=SQLOLEDB;Data Source=192.168.0.204;" &amp; _
                "Initial Catalog=ReportDB2;" &amp; _
                "Integrated Security=SSPI;"
  Set conn = New ADODB.Connection
  Set rs = New ADODB.Recordset
  
  conn.Open sConnString 
  Set rs = conn.Execute("SELECT * FROM Table1;")
  </code></pre>
  
  <p>It throws an error </p>
  
  <blockquote>
    <p>Cannot generate SSPI context</p>
  </blockquote>