Reputation: 1879
I have SQL Server 2008 R2 with a table that contains data ordered by numbers from 1 to 99999.
I want to connect to that table and show the last number of the row in my app, automatically without selecting anything.
How I could do it?
Thanks.
Upvotes: 1
Views: 1835
Reputation: 81
The SQL:
select top 1 from yourtable order by yournumericfield desc;
Or
select max(yournumericfield) from yourtable;
I notice that this is tagged Android. Android cannot talk directly with SQL Server. The easiest thing to do is to write a web service to sit in between the Android device and SQL Server:
Android --> Web Service -> SQL Server
You can perform standard HTTP communication in Java to talk to the web service. Your web service can talk to SQL Server using ADO in C++, or using the DB libraries in C#, perhaps. Or easier, using a web scripting language like ASP or ASP.NET, you can use the standard Windows DB functions.
Upvotes: 1
Reputation: 1563
If you will connect to the server from your Android App I would recommend using a webservice.
Take a look at this for example:
And you don't want to select anything? You can call a Stored Procedure maybe?
Upvotes: 2