How to write a REST API that will get or put onto a SQL server database

MrFlinstone 481 Reputation points
2021-09-16T14:05:34.88+00:00

Hi All.

I am looking to create an api such that a record can be written into a SQL server database. It will simply call a stored procedure with some data received. The api will return a status code to confirm if the insert has been successful or not.

The environment is on-premise (my laptop) and as such cannot use Azure functionality.

SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
12,745 questions
Microsoft Partner Center API
Microsoft Partner Center API
Microsoft Partner Center: A Microsoft website for partners that provides access to product support, a partner community, and other partner services.API: A software intermediary that allows two applications to interact with each other.
316 questions
Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,380 questions
{count} votes

Accepted answer
  1. Seeya Xi-MSFT 16,441 Reputation points
    2021-09-17T05:54:07.337+00:00

    Hi @MrFlinstone ,

    Please refer to this: https://www.zealousweb.com/calling-rest-api-from-sql-server-stored-procedure/
    AND https://hevodata.com/learn/sql-server-rest-api-integration/
    Hope these articles are helpful to you.

    Best regards,
    Seeya


    If the response is helpful, please click "Accept Answer" and upvote it, as this could help other community members looking for similar queries.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Limitless Technology 39,361 Reputation points
    2021-09-17T09:22:24.187+00:00

    Hello MrFlinstone,

    Runs a script containing statements supported by the SQL Server SQLCMD utility.

    The Invoke-Sqlcmd cmdlet runs a script containing the languages and commands supported by the SQL Server SQLCMD utility.

    The commands supported are Transact-SQL statements and the subset of the XQuery syntax that is supported by the database engine.

    This cmdlet also accepts many of the commands supported natively by SQLCMD, such as GO and QUIT.

    https://learn.microsoft.com/en-us/powershell/module/sqlserver/invoke-sqlcmd?view=sqlserver-ps

    Hope this answers all your queries, if not please do repost back.
    If an Answer is helpful, please click "Accept Answer" and upvote it : )

    Regards,

    0 comments No comments