+ Start a Discussion
Sanjeev R 1Sanjeev R 1 

how to fetch data from SQL SERVER to Apex List collection

I have a requirement that before inserting data I need to look for NAMES(codes) that are avavilabe some on the web in SQL SERVER database
I mean I have my SQL SERVER database accessible on the web... I need to query that database(table) from Apex and get the names of all the codes availabe like and hold that in a list collection in apex...like

List [] String  lstName = Select NAME from distributors;
(I mean in need to populate this list from SQL SERVER in apex.)

from here I can check if the incoming record has any of the name that is availabe in this list from SQL .. I will proceed with my code...

Please guide me is their a way to do so..its bascially etablishing connection between salesforce to SQL SERVER(or any other database).

Thanks in advance.

ShashankShashank (Salesforce Developers) 
Yopu will need to create a web service on your SQL server side and make an Apex callout from within apex code to that web service to fetch data.

I'm not an expert on SQL server web services, but this may help as a start: http://www.developer.com/net/asp/article.php/3767311/Creating-Native-Web-Services-in-SQL-Server.htm

For help on Apex callouts, please see "Apex Callouts" in this page: https://developer.salesforce.com/page/Apex_Web_Services_and_Callouts
Sanjeev R 1Sanjeev R 1

Hi Shashank,
Basically my objective is to populate my List (Map) here filled with the data, from the third party database. So that I can further query this collection and take conditional desicion on this List(Map) collection.

How can we populate List (Map) in Apwx from third party database.

thanks in advance