Check existence and non-existence of columns in a table

In this Bog, We will prepare a query which will tell us which tables has one specific column but another column which is also important is not present.QUERY-1select distinct TABLE_NAME from INFORMATION_SCHEMA.COLUMNS c where COLUMN_NAME=’column1′ and not exists ( select 1 from INFORMATION_SCHEMA.columns cc where cc.TABLE_NAME=c.TABLE_NAMEand cc.COLUMN_NAME=’column2′) The above Query will list all tables in which column1 is present and column2 is not present. QUERY-2select distinct TABLE_NAME from INFORMATION_SCHEMA.COLUMNS c where COLUMN_NAME=’column1′ and exists ( select 1 from INFORMATION_SCHEMA.columns cc where cc.TABLE_NAME=c.TABLE_NAMEand cc.COLUMN_NAME=’column2′) This Query will list all tables in…

get all Values separated by delimiter in sql

In this blog, I will discuss about “How to get all values separated by delimiter in SQL”. In one of my previous blog, where I have explained about positions of all delimiters present in a string. We will use same logic here as well. For example I have string with value abc@gmail.com;xyz@gmail.com;123@gmail,comIn the above string, I have three email ids which are separated by delimiter ; . I need these values in below format abc@gmail.comxyz@gmail.com123@gmail,com Use the below code to fetch the data in above format . declare @var1 varchar(100)…