Is there a SELECT … INTO OUTFILE equivalent in SQL Server Management Studio?

前端 未结 2 378
深忆病人
深忆病人 2020-11-28 13:58

MySQL had a nifty command SELECT ... INTO OUTFILE that could write the result set into a file (CSV format or some other optional format).

I am currentl

2条回答
  •  半阙折子戏
    2020-11-28 14:51

    In SSMS, "Query" menu item... "Results to"... "Results to File"

    Shortcut = CTRL+shift+F

    You can set it globally too

    "Tools"... "Options"... "Query Results"... "SQL Server".. "Default destination" drop down

    Edit: after comment

    In SSMS, "Query" menu item... "SQLCMD" mode

    This allows you to run "command line" like actions.

    A quick test in my SSMS 2008

    :OUT c:\foo.txt
    SELECT * FROM sys.objects
    

    Edit, Sep 2012

    :OUT c:\foo.txt
    SET NOCOUNT ON;SELECT * FROM sys.objects
    

提交回复
热议问题