edgarmtze
edgarmtze

Reputation: 25048

Export Result of query to file SQL Server

I have a complex query, when I execute it, I get a big table so I would like to export it to a file, instead of inserting it to a table.

for example, lets say we have a query:

select
  (select Name from Table1 where ID = 1),
  (select Name from Table2 where ID = 25),
   ...

How would I export result to a file?

Upvotes: 1

Views: 1805

Answers (1)

Ocaso Protal
Ocaso Protal

Reputation: 20247

You do this directly in SSMS? There is a button in the toolbar labeled Results To File which does exactly what you want. Or you can use openrowset

Upvotes: 1

Related Questions