简体   繁体   English

“ Azure移动服务”和“ Azure应用程序服务”之间的SQL结果不同

[英]Different sql results between “Azure Mobile Services” and “Azure App Service”

I got two different results when running the same SQL statements between Azure Mobile Service(the old service) and Azure App Service(the new service) 在Azure移动服务(旧服务)和Azure应用服务(新服务)之间运行相同的SQL语句时,我得到两个不同的结果

The SQL statement is: SQL语句是:

SELECT ROW_NUMBER() OVER(ORDER BY score_tot DESC) AS row, score_tot FROM Player

When i run it as an old Azure Mobile Service with the request.service.mssql.query() function i got a json result looking like this: 当我使用request.service.mssql.query()函数将其作为旧的Azure移动服务运行时,得到的json结果如下所示:

[ { row: 1 , score_tot: 45674 }, [{行: 1 ,score_tot:45674},

{ row: 2 , score_tot: 21234 }] {行: 2 ,score_tot:21234}]

but when i run the same SQL statement with the new Azure App Service using the request.azureMobile.data.execute(SQL) function i got this: 但是当我使用request.azureMobile.data.execute(SQL)函数使用新的Azure App Service运行相同的SQL语句时,得到以下信息:

[ { row: '1' , score_tot: 45674 }, [{row: '1' ,score_tot:45674},

{ row: '2' , score_tot: 21234 }] {row: '2' ,score_tot:21234}]

the App Service returns the row columns as a string/text and not as a number as it does in mobile service. App Service将行列作为字符串/文本而不是数字返回,而不是像在移动服务中那样返回数字。

Why is there a difference between these two results and what can i do to get the row columns as numbers in app service? 为什么这两个结果之间有区别,我该怎么做才能将行列作为应用服务中的数字? Shouldn't the app service return same results for same SQL statement as the old service? 应用服务是否应该针对相同的SQL语句返回与旧服务相同的结果?

/T / T

Per my experience, Azure Mobile Apps SDK for node.js uses node-mssql npm package as SQL Server driver. 根据我的经验,用于node.js的Azure移动应用程序SDK使用node-mssql npm程序包作为SQL Server驱动程序。 Following are my screenshot of testing, it seems that node-mssql lets ROW_NUMBER() function returns varchar value instead of int. 以下是我的测试屏幕快照,看来node-mssqlROW_NUMBER()函数返回varchar值而不是int。 程式码片段 返回结果

As a workaround, you could try to use the SQL below: 解决方法是,您可以尝试使用以下SQL:

SELECT CONVERT(INT, ROW_NUMBER() OVER(ORDER BY score_tot DESC)) AS row, score_tot FROM Player

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM