ASPForums.Net RSS Feedhttp://www.aspforums.net/Handlers/RSS.ashxLatest additions to the content that appears on ASPForums.Net(c) 2019 www.aspforums.com. All rights reserved.Query to delete record from two tables iin SQL Server<p>Hi <a class="username" rel="ps222"> ps222</a>,</p> <p>Refer the below query.</p> <p><strong><span style="text-decoration: underline;">SQL</span></strong></p> <pre class="brush: sql">CREATE TABLE t1 (tid INT,Name CHAR(10),Start_Date DATETIME) INSERT INTO t1 VALUES(1,&#39;Name 1&#39;,&#39;2018-05-01&#39;) INSERT INTO t1 VALUES(2,&#39;Name 2&#39;,&#39;2018-05-03&#39;) INSERT INTO t1 VALUES(3,&#39;Name 3&#39;,&#39;2018-05-04&#39;) INSERT INTO t1 VALUES(4,&#39;Name 4&#39;,&#39;2018-05-12&#39;) INSERT INTO t1 VALUES(5,&#39;Name 5&#39;,&#39;2018-05-13&#39;) CREATE TABLE t2 (tid INT,Age INT) INSERT INTO t2 VALUES(1,15) INSERT INTO t2 VALUES(2,12) INSERT INTO t2 VALUES(3,13) INSERT INTO t2 VALUES(4,14) INSERT INTO t2 VALUES(5,18) DELETE FROM t2 WHERE t2.tid IN (SELECT tid FROM t1 WHERE t1.Start_Date BETWEEN &#39;2018-05-01&#39; AND &#39;2018-05-10&#39;) DELETE FROM t1 WHERE t1.Start_Date BETWEEN &#39;2018-05-01&#39; AND &#39;2018-05-10&#39; SELECT * FROM t1 SELECT * FROM t2</pre> <p><strong><span style="text-decoration: underline;">Output</span></strong></p> <p><strong>t1</strong></p> <table border="1"> <tbody> <tr> <td>tid</td> <td>Name</td> <td>Start_Date</td> </tr> <tr> <td>4</td> <td>Name 4</td> <td>2018-05-12 00:00:00.000</td> </tr> <tr> <td>5</td> <td>Name 5</td> <td>2018-05-13 00:00:00.000</td> </tr> </tbody> </table> <p><strong>t2</strong></p> <table border="1"> <tbody> <tr> <td>tid</td> <td>Age</td> </tr> <tr> <td>4</td> <td>14</td> </tr> <tr> <td>5</td> <td>18</td> </tr> </tbody> </table>https://www.aspforums.net:443/Threads/779055/Query-to-delete-record-from-two-tables-iin-SQL-Server/https://www.aspforums.net:443/Threads/779055/Query-to-delete-record-from-two-tables-iin-SQL-Server/Mon, 15 Oct 2018 04:09:53 GMT