Home Forums SQL Server 2005 Development execute SQL server query from Dos command prompt/ batch file. RE: execute SQL server query from Dos command prompt/ batch file.

  • Yes, use SQLCMD. However, if you don't like the output format that SQLCMD provides and/or you want to massage the data a bit before writing to the file, the next step up would be a quick VBScript (executed by CSCRIPT) using the SQL Server Provider for OLE-DB.

    I do it all the time to produce delimited (e.g., tab, pipe, etc.) flat files as well as to extract BLOBs (former TEXT and IMAGE data types) out as separate files in the file system.


    [font="Arial Narrow"](PHB) I think we should build an SQL database. (Dilbert) What color do you want that database? (PHB) I think mauve has the most RAM.[/font]