SQLTeam.com | Weblogs | Forums

Is there an easy way to populate a column with an INDEX/MATCH statement?


In Excel, you can use INDEX/MATCH to check particular cells in the table and then populate a third column with respective values.

How can this be achieved with SQL? What is the equivalent of INDEX/MATCH?


It's a JOIN. There are numerous examples in the SQL Server documentation.

You've posted a question that suggests you understand how JOINs work:

I need to populate 15 columns with Y or N based on the INDEX/MATCH result on the other columns of the SELECTION.

If I have to do joins, it will get really messy.

The only reason that multiple JOINs would get messy is if you're dealing with a messy data model. I have no way of knowing that without seeing specific details of your tables and columns.

My previous job had views and stored procedures that would JOIN 30 or more tables, sometimes 70. While verbose, once it's written it's relatively static and not too difficult to maintain.

1 Like