DEV Community

Vlada Maksymiuk
Vlada Maksymiuk

Posted on

From SQL Server to SFTP — 5 Practical Options to Automate Secure File Deliveries

The article was initially published on the Skyvia blog.

If you’ve ever found yourself manually exporting a table to CSV, then uploading it via SFTP only to scramble when someone misses the schedule — you know the drill.

There’s a better way. In fact, there are five ways to reliably send SQL Server data to an SFTP server — ranging from manual to fully automated pipelines. Below are the options, and who they fit best.

Why SFTP Still Matters

SFTP (SSH File Transfer Protocol) remains widely used because it offers encrypted, secure file transfer over SSH. Everything — commands, data, credentials — travels inside a protected tunnel.

Pairing SQL Server with SFTP works well when you need:

  • Nightly exports for reporting or backup
  • Delivering data to partners/vendors who expect file drops
  • Compliance with data-in-transit encryption (GDPR, HIPAA, etc.)
  • A neutral “exchange zone” — an SFTP folder works for any system that can pick up files

But doing this manually doesn’t scale. That’s why you need a repeatable, automated approach when volume or reliability matters.

5 Ways to Move Data from SQL Server → SFTP

Method 1: Manual Export + SFTP Upload

Simple, old-school — open SQL Server Management Studio ➝ export table/view ➝ save as CSV ➝ login to SFTP client and upload.
Great if you just need a quick one-off file.
But once this becomes daily or weekly — it’s a recipe for missed uploads, wrong files, or burned-out teammates.

Best For

Occasional exports, quick fixes — no code required, works on any machine

Cons

Fully manual; error-prone; no scheduling; not scalable

Method 2: Scripting (PowerShell / Python)

Write a short script that:

  • Queries SQL Server, exports results to CSV
  • Connects to SFTP server (via SSH/SFTP library or tool like WinSCP)
  • Pushes the file and optionally logs or sends notifications

This becomes fully automated once scheduled (cron job, Windows Task Scheduler, etc.). Ideal for small teams that want automation without heavy infrastructure, but expect someone will need to maintain the script.

Best For

Teams comfortable with scripting, need automation & flexibility

Cons

Requires maintenance, error handling, scheduling setup

Method 3: SSIS + SFTP Plugin

If your stack already uses SQL Server Integration Services, you can build a pipeline that:

  • Extracts data from SQL Server
  • Transforms / filters if needed
  • Saves to file (CSV, for example)
  • Uploads to SFTP using a plugin or third-party component

This is a solid option for large or complex workflows, especially inside enterprises that already have MS-SQL / SSIS in place. Setup takes effort, though — and you’ll likely need extra licensing for SFTP support.

Best For

Complex or large-scale jobs, existing SSIS usage

Cons

Needs Visual Studio, plugins, licensing; setup + maintenance overhead

Method 4: Linked Server + SFTP ODBC Driver

This is more niche and technical — it involves installing a driver that exposes an SFTP folder as if it were a database. Then SQL Server can target it as a “remote table,” and you can SELECT/INSERT data into it directly.

It’s clever, but fragile — driver compatibility, licensing, and maintenance volume often outweigh the benefits. Use it only if your compliance or environment constraints forbid external tools.

Best For

Niche cases where DB-native solutions are mandated

Cons

Fragile, technical, often expensive and hard to maintain

Method 5: Cloud-based Integration Platforms

For many teams — analysts, ops, product owners — this is the easiest path. Cloud integration platforms offer a no-code/low-code GUI: define your SQL Server source, define your SFTP target, pick tables or queries, schedule the job — done.

Best For

Analysts or ops teams wanting “set and forget” automation without code

Cons

Dependence on cloud, initial setup of credentials/firewall, subscription cost

What to Watch Out For (Best Practices)

No matter which method you pick, keep these in mind:

  • Use SFTP, not FTP. SFTP encrypts data in transit. FTP does not — plain text + passwords = bad idea.
  • Sanitize and standardize your data exports. Consistent CSV schema, clean headers, stable formats (e.g. ISO date format) help avoid errors downstream.
  • Enable error handling, logging, and alerts. Automated pipelines still fail — make sure you’re notified when they do.
  • Plan for scale. Small weekly exports might be fine manually, but if you move millions of rows regularly: think incremental exports, compression, bandwidth, and scheduling strategy.
  • Mind security and compliance. Keep SFTP credentials and SSH keys safe. Limit IP access. Encrypt storage if needed.

Which Method Should You Use?

  1. Quick fix or one-time job: Manual export + upload
  2. Light automation without heavy tools: Script
  3. Robust, enterprise-grade integration within SQL Server ecosystem: SSIS + SFTP
  4. Edge case or strict DB-only environments: Linked Server + SFTP driver
  5. Fastest, lowest-maintenance way to go automated: Cloud-based integration platform

If you care about time savings and reliability — go with automation.

If you care about minimal tools and cost — scripting or a cloud integration tool may hit the sweet spot.

Final Thoughts

Even though file-based pipelines like SQL → CSV → SFTP might feel old-school now, they're still deeply relevant. Many external systems (legacy apps, vendor portals, partner data warehouses) expect file drops — and SFTP remains the standard for secure file transfer.

By automating the handoff between your database and SFTP, you remove a recurring pain point from your workflow — and avoid the “did someone upload the file?” panic on a Friday evening.

Top comments (0)