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.Check if record Exists in Database in SQL Server<p>Hey <a class="username" rel="rakibxl"> rakibxl</a>,</p> <p>Please refer below sample.</p> <p><span style="text-decoration: underline;"><strong>SQL</strong></span></p> <pre class="brush: sql">DECLARE @FatherSonRelation AS TABLE(IDCustomerFather VARCHAR(10), IDCustomerSon VARCHAR(10)) INSERT INTO @FatherSonRelation VALUES(&#39;A&#39;,&#39;B&#39;) DECLARE @Father VARCHAR(10) DECLARE @Son VARCHAR(10) SET @Father=&#39;B&#39; SET @Son=&#39;A&#39; IF EXISTS(SELECT * FROM @FatherSonRelation WHERE (IDCustomerFather=@Father AND IDCustomerSon=@son) OR (IDCustomerFather=@Son AND IDCustomerSon=@Father)) BEGIN PRINT &#39;You Can not insert&#39; END ELSE BEGIN INSERT INTO @FatherSonRelation VALUES(@Father, @Son) SELECT * FROM @FatherSonRelation END</pre>https://www.aspforums.net:443/Threads/106868/Check-if-record-Exists-in-Database-in-SQL-Server/https://www.aspforums.net:443/Threads/106868/Check-if-record-Exists-in-Database-in-SQL-Server/Thu, 06 Dec 2018 23:10:26 GMT