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 Column Exists in Database Table in SQL Server<p>Hey <a class="username" rel="NerakSeven">NerakSeven</a>,</p> <p>Please refer below query.</p> <p><span style="text-decoration: underline;"><strong>SQL</strong></span></p> <pre class="brush: sql">CREATE TABLE TesCode(A1 VARCHAR(200)) INSERT INTO TesCode VALUES(&#39;110201&#39;) DECLARE @codigo NVARCHAR(200) DECLARE @column NVARCHAR(200) SET @codigo = &#39;110201&#39; SET @column = &#39;A1&#39; IF EXISTS (SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = &#39;TesCode&#39; AND COLUMN_NAME = @column) BEGIN DECLARE @sqlQuery NVARCHAR(MAX); SET @sqlQuery = N&#39;SELECT &#39;+ @column + &#39; FROM TesCode WHERE &#39; + @column + &#39; = &#39;&#39;&#39; + @codigo + &#39;&#39;&#39;&#39; EXEC (@sqlQuery) END</pre>https://www.aspforums.net:443/Threads/208764/Check-if-Column-Exists-in-Database-Table-in-SQL-Server/https://www.aspforums.net:443/Threads/208764/Check-if-Column-Exists-in-Database-Table-in-SQL-Server/Tue, 11 Dec 2018 05:36:11 GMT