title: Connecting an PLC Siemens S7-1500 to an SQL Server Database
body: <p>The connection guide is <a href="https://support.industry.siemens.com/cs/document/109779336/connecting-an-s7-1500-to-an-sql-database-?dti=0&amp;lc=en-WW" rel="noreferrer">here</a>. I track the guide and do a lot of stuff.
  The connection between PLC and SQL server is <strong>ok</strong>, I've login successfully to SQL.<br />
  I can <code>insert</code> to tables, <code>update</code>, and execute <code>store procedures</code>.</p>
  <p>But when I run a <code>select</code> query I don't know how to retrieve data and <strong>read</strong> the values.</p>
  <p><a href="https://i.stack.imgur.com/j4va3.png" rel="noreferrer"><img src="https://i.stack.imgur.com/j4va3.png" alt="Tia Portal" /></a></p>
  <p>I use TIA PORTAL v16.</p>
  <p>PLC: S7 1200 siemens</p>
  <p>I have a simple table, I wanna simply read an integer, first with one row! then expand my work.</p>
  <p>This is my table structure:</p>
  <pre><code>CREATE TABLE MyTable(
  [id] [int] IDENTITY(1,1) NOT NULL,
  [value] [int] NOT NULL,
  )
  ) ON [PRIMARY]
  </code></pre>
  <p>and this is my <code>select</code> query:</p>
  <pre><code>SELECT [value]
  FROM [dbo].[MyTable]
  WHERE id = 12033
  </code></pre>
  <p>expected result:</p>
  <pre><code>20
  </code></pre>
  <p><a href="https://i.stack.imgur.com/9TW5F.png" rel="noreferrer"><img src="https://i.stack.imgur.com/9TW5F.png" alt="SQL shot" /></a></p>
  <p><a href="https://support.industry.siemens.com/tf/ww/en/posts/connecting-an-plc-siemens-s7-1500-to-an-sql-server-database/239392/?page=0&amp;pageSize=10#post939400" rel="noreferrer">https://support.industry.siemens.com/tf/ww/en/posts/connecting-an-plc-siemens-s7-1500-to-an-sql-server-database/239392/?page=0&amp;pageSize=10#post939400</a></p>
  <h2>UPDATE</h2>
  <p>I answered my own question, Please attention, Siemens recently (11/20/2020) published a document about Connecting an S7-* series to Microsoft SQL Server Database, directly. So the verfied anwser is the classic and normal way to connect PLC to SQL Server and the next answer is the latest native solution.
  Have fun</p>