Script to save varbinary data to disk

后端 未结 8 1778
无人及你
无人及你 2020-11-28 07:17

I have some varbinary data stored in a table in MS Sql Server 2005. Does anyone have SQL code that takes a query as input (lets say the query guarantees that a single colum

8条回答
  •  一整个雨季
    2020-11-28 08:03

    SQL is designed to work with database objects, so from it's point of view anything else doesn't exists. Sure, there are extended procedures like xp_cmdshell that allow you interact with the operating system, but they are proprietary extensions and not part of T-SQL.

    Maybe the closest approach would be using the FILESTREAM attribute for binary types of SQL Server 2008, which allow storing some columns directly as files in a folder instead of using the database:

    FILESTREAM overview

    Note that the FILESTREAM storage is designed for maintain large files out of the database in order to increase performance, and not for allowing direct access to files (i.e. T-SQL still doesn't have the concept of a filesystem). I my opinion, direct access to the filesystem from SQL will defeat some of the purposes of a database (mainly having data stored in a structured way).

    So I would recommend following the advice of Dustin and use a tool like BCP or any other data dumper.

提交回复
热议问题