Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have geometry data in SQL Server 2008 R2. How do I load that spatial data using the ArcGIS Javascript API?

share|improve this question

Write a WCF service that returns a JSONP response. WCF service should return a data in following format:

    "feature": {
        "attributes": {
            "objectid": 1,
            "fdate": 932428800000,
            "resolution": 3,
            "gnis_id": null,
            "gnis_name": null,
            "lengthkm": 0.024,
            "reachcode": "11070101001016",
            "flowdir": 1,
            "wbareacomid": null,
            "ftype": 558,
            "fcode": 55800,
            "enabled": 1
        "geometry": {
            "paths": [
share|improve this answer

you cannot access any kind of data with any web API if that data isn't published in an ArcGIS Server map service (or WMS, or KML, etc.). Nor a sql server spatial data, neither any "classic" ArcGIS data (shapefile, featureclass inside a geodatabase, etc). you have to setup an mxd project with that data loaded (you can load spatial data from sql server) and then publish it as map service on ArcGIS server. all the web API (Flex, Silverlight, Javascript) work only over web available map services (in particular http REST with ArcGIS server). hope this helps

share|improve this answer
Thanks for your reply.I saw a post like this for Silverlight api.I am looking for the same for Javasctipt api. – SureshRajamani Mar 1 '12 at 10:20
I had to downvote this for obvious reasons. Data published in via an ArcGIS Server service is easier to use, but it is not the only way to get data to your map service. This is older, but it can still be a resource for newbies. There are extensions to ESRI JS API as well as other types of Layers that would be able to use data from different sources. Ever hear of JSON? – Branco Jun 16 '15 at 0:24

I don't have time to try out the specifics, but it might not be too difficult to add data retrieved from SQL Server to an graphics layer on your map. Here's a somewhat related example

Looks like the architecture is pretty sound, even though the final product may not be exactly what you're looking for.

Also, as robmyes mentioned, a more straightforward approach may be to format your data in ArcMap and publish a map service that directly references your data in SQL Server. I've played around with Query Layers (new in ArcGIS 10) and was pretty impressed. No SDE requirement!

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.