Click here to Skip to main content
15,921,779 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi All,

So far I was doing some excel functions manually like vlookup(), Now I would like to automate this vlookup() function through query sql-server 2005.

Do we have vlookup() function in sqlserver-2005.
Posted
Updated 24-Jan-12 0:11am
v2

1 solution

There is no direct vlookup function in SQL server, but to be honest, vlookup is a difficult way to do it anyway.

If you use the examples in this vlookup page:http://www.techonthenet.com/excel/formulas/vlookup.php[^]

Then the SQL equivalent would be:
SQL
SELECT Product FROM pvtTable WHERE OrderID=10251

SQL
SELECT UnitPrice FROM pvtTable WHERE OrderID=10251

SQL
SELECT Product FROM pvtTable WHERE OrderID=10248
The final one would return no records.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900