# Error when accessing MS SQL Views

**URL:** <https://community.dreamfactory.com/t/error-when-accessing-ms-sql-views/764>\
**Category:** Connecting to SQL\
**Created:** [January 19, 2015, 7:24am UTC](https://community.dreamfactory.com/t/error-when-accessing-ms-sql-views/764 "2015-01-19T07:24:37Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![samsabra](https://avatars.discourse-cdn.com/v4/letter/s/ee59a6/32.png) [@samsabra](https://community.dreamfactory.com/u/samsabra)\
**Post date:** [January 19, 2015, 7:24am UTC](https://community.dreamfactory.com/t/error-when-accessing-ms-sql-views/764/1 "2015-01-19T07:24:37Z")

</div>

Hi,

I’d like to thank you all for the great work you’ve done in developing an excellent open-source product.

I’ve set up a few services in dreamfactory that access an MS SQL Server database. Everything was working well, but I realized I needed to performs joins in my queries. It appears that the best way to do this is create views (please correct me if there is currently a better way to perform joins).

I’ve created a couple of views and tried to access them from the API and I’ve receiving the following error:

> Failed to retrieve records from ‘usercontact’.\nCDbCommand failed to execute the SQL statement: SQLSTATE[HY000]: General error: 102 General SQL Server error: Check messages from the SQL Server [102] (severity 15) [(null)]

I then tried to access the views from the Data tab in the Admin. After selecting the service, the views appears in the drop down with the tables in the database. After selecting the view and clicking the “Set Service” button, I see the following errors pop-up:

> API Error  
> Failed to retrieve records from ‘usercontact’.  
> CDbCommand failed to execute the SQL statement: SQLSTATE[HY000]: General error: 102 General SQL Server error: Check messages from the SQL Server [102] (severity 15) [(null)]

and

> DreamFactory Table Module  
> DreamFactory Table Module: Failed to retrieve records from ‘usercontact’.  
> CDbCommand failed to execute the SQL statement: SQLSTATE[HY000]: General error: 102 General SQL Server error: Check messages from the SQL Server [102] (severity 15) [(null)]

I’m able to perform select statements on these views when I log into SSMS under the same user account, so I do not believe this to be a permissions issue.

Please advise.

Thanks,

Sam

---

<div class="post-metadata">

**Author:** ![jeffreystables](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.dreamfactory.com/jeffreystables/32/173_2.png) [@jeffreystables](https://community.dreamfactory.com/u/jeffreystables)\
**Post date:** [January 20, 2015, 3:56pm UTC](https://community.dreamfactory.com/t/error-when-accessing-ms-sql-views/764/2 "2015-01-20T15:56:04Z")

</div>

We are testing calling views from the DSP for MySQL and SQL Server DBs now and will report back with details.

What is logged in your DSP’s log files when these errors are thrown? And what version of SQL Server are you connecting to?

---

<div class="post-metadata">

**Author:** ![Kagemaru](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.dreamfactory.com/kagemaru/32/238_2.png) [@Kagemaru](https://community.dreamfactory.com/u/Kagemaru)\
**Post date:** [March 5, 2015, 6:12pm UTC](https://community.dreamfactory.com/t/error-when-accessing-ms-sql-views/764/3 "2015-03-05T18:12:01Z")

</div>

I’ve encountered the same error.

```
   {
  "error": [
    {
      "context": null,
      "message": "Failed to retrieve records from 'Sicht_Buchungsliste'.\nCDbCommand failed to execute the SQL statement: SQLSTATE[HY000]: General error: 1038 General SQL Server error: Check messages from the SQL Server [1038] (severity 15) [(null)]",
      "code": 500
    }
  ]
}

```

I’m using the hosted version of Dreamfactory and MSSQL Version:

```
Microsoft SQL Server 2008 R2 (SP1) - 10.50.2550.0 (X64) Jun 11 2012 16:41:53 Copyright (c) Microsoft Corporation Standard Edition (64-bit) on Windows NT 6.1 <X64> (Build 7601: Service Pack 1) (Hypervisor)
```

---

<div class="post-metadata">

**Author:** ![jeffreystables](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.dreamfactory.com/jeffreystables/32/173_2.png) [@jeffreystables](https://community.dreamfactory.com/u/jeffreystables)\
**Post date:** [March 5, 2015, 6:24pm UTC](https://community.dreamfactory.com/t/error-when-accessing-ms-sql-views/764/4 "2015-03-05T18:24:08Z")

</div>

Could you let me know the name of your sandbox DSP and the contents of the SQL view you’re calling?

---

<div class="post-metadata">

**Author:** ![Kagemaru](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.dreamfactory.com/kagemaru/32/238_2.png) [@Kagemaru](https://community.dreamfactory.com/u/Kagemaru)\
**Post date:** [March 12, 2015, 12:18am UTC](https://community.dreamfactory.com/t/error-when-accessing-ms-sql-views/764/5 "2015-03-12T00:18:25Z")

</div>

The DSP name is

```
stundenbuchungsapp

```

The view I’m trying to load is Sicht\_Buchungsliste and I’d have uploaded an image of what’s in it, but I’m a new user and can’t upload pics. :\

---

<div class="post-metadata">

**Author:** ![Kagemaru](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.dreamfactory.com/kagemaru/32/238_2.png) [@Kagemaru](https://community.dreamfactory.com/u/Kagemaru)\
**Post date:** [March 12, 2015, 11:08am UTC](https://community.dreamfactory.com/t/error-when-accessing-ms-sql-views/764/6 "2015-03-12T11:08:51Z")

</div>

I think I’ve found my problem.  
As soon as the results have one one field with an Umlaut in the value, the whole request seems to fail.

---

<div class="post-metadata">

**Author:** ![jeffreystables](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.dreamfactory.com/jeffreystables/32/173_2.png) [@jeffreystables](https://community.dreamfactory.com/u/jeffreystables)\
**Post date:** [March 16, 2015, 6:31pm UTC](https://community.dreamfactory.com/t/error-when-accessing-ms-sql-views/764/7 "2015-03-16T18:31:10Z")

</div>

It may indeed be a formatting or encoding problem due to the special character. However I’m unable to find any sandbox DSP at [dsp-stundenbuchungsapp.cloud.dreamfactory.com](https://dsp-stundenbuchungsapp.cloud.dreamfactory.com) or [stundenbuchungsapp.cloud.dreamfactory.com](https://stundenbuchungsapp.cloud.dreamfactory.com) so I can’t say what is being logged. Are you certain this is the name of your free hosted DSP?

---

<div class="post-metadata">

**Author:** ![Kagemaru](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.dreamfactory.com/kagemaru/32/238_2.png) [@Kagemaru](https://community.dreamfactory.com/u/Kagemaru)\
**Post date:** [March 22, 2015, 5:44pm UTC](https://community.dreamfactory.com/t/error-when-accessing-ms-sql-views/764/8 "2015-03-22T17:44:46Z")

</div>

Oh sorry, it’s [dsp-ks.cloud.dreamfactory.com](https://dsp-ks.cloud.dreamfactory.com).

Stundenbuchungsapp is the app inside the dsp.

---

<div class="post-metadata">

**Author:** ![jeffreystables](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.dreamfactory.com/jeffreystables/32/173_2.png) [@jeffreystables](https://community.dreamfactory.com/u/jeffreystables)\
**Post date:** [April 14, 2015, 1:13pm UTC](https://community.dreamfactory.com/t/error-when-accessing-ms-sql-views/764/9 "2015-04-14T13:13:10Z")

</div>

I’m glad you’ve identified the issue. Please let me know if you require any further assistance.

---

<div class="post-metadata">

**Author:** ![Kagemaru](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.dreamfactory.com/kagemaru/32/238_2.png) [@Kagemaru](https://community.dreamfactory.com/u/Kagemaru)\
**Post date:** [April 14, 2015, 1:35pm UTC](https://community.dreamfactory.com/t/error-when-accessing-ms-sql-views/764/10 "2015-04-14T13:35:26Z")

</div>

Does that mean it will not be possible to use Umlauts with your service? Since our business is located in Switzerland, that’s pretty much a necessary requirement for us.

---

<div class="post-metadata">

**Author:** ![jeffreystables](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.dreamfactory.com/jeffreystables/32/173_2.png) [@jeffreystables](https://community.dreamfactory.com/u/jeffreystables)\
**Post date:** [April 14, 2015, 4:18pm UTC](https://community.dreamfactory.com/t/error-when-accessing-ms-sql-views/764/11 "2015-04-14T16:18:48Z")

</div>

Sorry, I thought you said you had identified the issue.

We have tested storing and retrieving data with the umlaut character in SQL Server and not encountered an error.

First, I recommend trying to pull the same data through same view in another SQL Server client. See if the same error is given.

Next, try storing and then retrieving some data with umlauts, both through DSP. Create the records through DSP and then retrieve them, to see if the error is prevented if the DSP is the one that creates the records.

If neither of these gives any insight, could you provide a dump of the records returned from the view so we can see it and test on our own? (Or at least a sample of the data that causes this error.) Additionally, what are the collation and charset settings on the data in question?
