Selasa, 27 Juli 2021

How to enclose a list of values into single quotes for SQL query? Microsoft Excel Example

Many times you get a list of values that you want to check in the database to confirm if they exist in your tables or to get more information bout them. For example, you got a list of 100 stocks and you want to check their last day closing prices in the database. The problem arises when values to be searched are Strings e.g. VARCHAR or CHAR because VARCHAR values need to be enclosed in the single quotes in most of the database like SQL Server, Oracle, or MySQL. If a number of values are less than 5 then it makes sense to add single quotes around them and separate them by comma manually so that you can use them on IN clause of your SQL query, but if it's more than 5 like 50 or 100 then manually enclosing them into single quotes will take a lot of time and most importantly programmers are not supposed to do such silly stuff manually.

Lorem ipsum is simply dummy text of the printing and typesetting industry.

Comments


EmoticonEmoticon