Create comma seperated text values for In SQL Query from excel file
Problem : You are provided with excel containing First Name. You want to write employee details with this first name. This will help you to quickly create comma separated text values which you can use In SQL Query
Solution :
1. You are provided an excel with First Name
2. Select First Name column and Right Click and Select Format Cells
3. Select Custom -> Type ‘@’, and Click on Ok
4. On click of OK , you will get comma seperated text value which you can use in In SQL Query. Remove the last comma
5. Copy rows in First Name column ( Do not copy column header if any ) and paste it in new SQL Query file in SQL Management studio :
select * from Employee where FirstName in
(
‘Santosh’, |
‘Raman’, |
‘Rakesh’, |
‘Rajesh’, |
‘Suresh’, |
‘Tom’, |
‘Brain’, |
‘Susan’, |
‘Alok’, |
‘Sushil’, |
‘Subodh’, |
‘Alexander’, |
‘Oliver’, |
‘Michael’, |
‘John’, |
‘Ramesh’, |
‘Ali’, |
‘Mohammed’, |
‘Traci’, |
‘Ewan’, |
‘Amit’, |
‘Karan’, |
‘Sakti’ ) |