tsql using json

  • hi

    i have one web application and i need to fetch data from underlying table.

    i have url and vendor wants to fetch data using json .

    i just have username,password and db name.

    how to use tsql to login and fetch data using url and db name?

     

  • Thanks for posting your issue and hopefully someone will answer soon.

    This is an automated bump to increase visibility of your question.

  • In 2008, there is not return of data in JSON format. You can construct something, but you'd have to provide more information.

    Query your table to return the data, using the parameters your application passes in. I'd suggest you do this in a stored procedure rather than a query, as if there are issues, you can more easily tune your code in a procedure.

    String manipulation can construct a string of JSON by concatenating [ and { as needed.

     

  • we are using sql server 2016. but first how to connect using stored proc to web url.

  • I assume you mean someone accessing a web URL will then cause a stored procedure to execute?

    SQL Server isn't built to function as a web server. You would build a web app which connects to SQL Server and then calls a stored procedure. This might help: https://stackoverflow.com/questions/52213194/how-to-execute-call-stored-procedure-from-asp-net-web-api

    Your web application needs to make a connection to SQL Server, just like any client application, and then call a stored procedure. Please use the Stored Procedure type in your connection, not just sending through an ad hoc batch request. We have enough SQL Injection issues and don't need more.

    Your code on the web server can then serialize or deserialize JSON.

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply