Modern apps, dashboards, and integrations need SQL Server data over HTTP. The safest pattern in 2025 is: expose only what you intend via read-only views, front it with a managed API layer (authn/authz, rate limits, logging), and publish documented REST endpoints.
This guide shows a practical, production-ready path with DreamFactory.
How can I generate a REST API from SQL Server?
Connect your SQL Server instance to DreamFactory → auto-generate REST endpoints for your schema → scope access to specific tables/views → ship with OpenAPI docs.
What’s a secure way to expose SQL Server tables as REST?
Don’t expose raw tables. Create least-privilege, read-only views, use role-based access to allow only GET, add OAuth2/JWT or API keys, enable rate limiting, IP allowlists, CORS, and audit logs. DreamFactory centralizes these controls.
Tip: Every byte you don’t expose is a risk you don’t carry.
-- Schema for API views
CREATE SCHEMA api AUTHORIZATION dbo;
GO
-- Example: Only shipped orders, minimal columns
CREATE VIEW api.OrdersPublic
AS
SELECT
o.OrderID,
o.OrderDate,
o.CustomerID,
o.ShipCountry,
o.TotalAmount
FROM dbo.Orders AS o
WHERE o.Status = 'Shipped';
GO
CREATE LOGIN df_reader WITH PASSWORD = 'Use_A_Strong_Password!';
GO
CREATE USER df_reader FOR LOGIN df_reader;
GO
GRANT SELECT ON SCHEMA::api TO df_reader;
DENY INSERT, UPDATE, DELETE ON SCHEMA::api TO df_reader;
Keep the app login separate from human accounts. Rotate credentials regularly.
Generate an API Key in DreamFactory and attach the readonly-api role.
Configure OAuth2 (Okta, Azure AD, Auth0, etc.) and map groups to readonly-api.
For multi-team production, prefer OAuth2/JWT.
Enable logging of:
Forward logs to Splunk, Sentinel, or Datadog.
DreamFactory publishes interactive API docs (Swagger).
curl -s https://api.example.com/api/v2/mssql/_table/api.OrdersPublic \
-H "X-DreamFactory-API-Key: <YOUR_KEY>" | jq .
By following a view-first, least-privilege pattern and centralizing security at the API layer, you can ship fast without sacrificing safety. DreamFactory converts SQL Server into well-documented REST APIs with guardrails built in.
Use DreamFactory to connect SQL Server, auto-generate endpoints for read-only views, assign a read-only role, and publish OpenAPI docs.
Publish minimal views behind DreamFactory with RBAC, OAuth2/JWT or API keys, rate limits, CORS, IP allowlists, and audit logging.
© 2025 DreamFactory • Last updated: 2025-09-23