国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 數據庫 > SQL Server > 正文

MS SQL SERVER 圖像或大文本的輸入輸出

2024-08-31 00:50:49
字體:
來源:轉載
供稿:網友

在MS SQL SERVER 安裝目錄下有個可執行文件叫 TEXTCOPY.EXE
可對 MS SQL SERVER 中的文本或圖像數據進行輸入輸出.
不過你可以在MS-DOS方式下執行textcopy /? 得到它的描述。
下面是這個工具的描述:
Copies a single text or image value into or out of SQL Server. The val
ue
is a specified text or image 'column' of a single row (specified by th
e
"where clause") of the specified 'table'. 

If the direction is IN (/I) then the data from the specified 'file' is

copied into SQL Server, replacing the existing text or image value. If
the
direction is OUT (/O) then the text or image value is copied from
SQL Server into the specified 'file', replacing any existing file.

TEXTCOPY [/S ][sqlserver]] [/U [login]] [/P ][passWord]]
  [/D ][database]] [/T table] [/C column] [/W"where clause"]
  [/F file] [{/I | /O}] [/K chunksize] [/Z] [/?]

  /S sqlserver       The SQL Server to connect to. If 'sqlserver' is n
ot
                     specified, the local SQL Server is used.
  /U login           The login to connect with. If 'login' is not spec
ified,
                     a trusted connection will be used.
  /P password        The password for 'login'. If 'password' is not
                     specified, a NULL password will be used.
  /D database        The database that contains the table with the tex
t or
                     image data. If 'database' is not specified, the d
efault
                     database of 'login' is used.
  /T table           The table that contains the text or image value.

  /C column          The text or image column of 'table'.
  /W "where clause"  A complete where clause (including the WHERE keyw
ord)
                     that specifies a single row of 'table'.
  /F file            The file name.
  /I                 Copy text or image value into SQL Server from 'fi
le'.
  /O                 Copy text or image value out of SQL Server into '
file'.
  /K chunksize       Size of the data transfer buffer in bytes. Minimu
m
                     value is 1024 bytes, default value is 4096 bytes.

  /Z                 Display debug information while running.
  /?                 Display this usage information and exit.

You will be PRompted for any required options you did not specify.

為此, 可寫一個存儲過程,調用這個命令
CREATE PROCEDURE sp_textcopy (
  @srvname     varchar (30),
  @login       varchar (30),
  @password    varchar (30),
  @dbname      varchar (30),
  @tbname      varchar (30),
  @colname     varchar (30),
  @filename    varchar (30),
  @whereclause varchar (40),
  @direction   char(1))
AS
DECLARE @exec_str varchar (255)
SELECT @exec_str =
         'textcopy /S ' + @srvname +
         ' /U ' + @login +
         ' /P ' + @password +
         ' /D ' + @dbname +
         ' /T ' + @tbname +
         ' /C ' + @colname +
         ' /W "' + @whereclause +
         '" /F ' + @filename +
         ' /' + @direction
EXEC master..xp_cmdshell @exec_str

下面是一個拷貝圖像到SQL Server的pubs數據庫的例子, 表名pub_info, 字段名
logo,圖像文件名picture.bmp,保存到pub_id='0736'記錄 sp_textcopy @srvn
ame = 'ServerName',
            @login = 'Login',
            @password = 'Password',
            @dbname = 'pubs',
            @tbname = 'pub_info',
            @colname = 'logo',
            @filename = 'c:/picture.bmp',
            @whereclause = " WHERE pub_id='0736' ",
            @direction = 'I'


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 佛学| 临西县| 汝城县| 海伦市| 桃园市| 休宁县| 枝江市| 胶南市| 德令哈市| 屯昌县| 陇南市| 汾阳市| 宁乡县| 玉林市| 澄江县| 延安市| 若羌县| 门源| 武功县| 邵阳市| 嫩江县| 巫溪县| 泗水县| 靖安县| 专栏| 新乐市| 武汉市| 腾冲县| 类乌齐县| 冀州市| 灵丘县| 博爱县| 上林县| 泸西县| 海丰县| 明水县| 义乌市| 肥东县| 桃园市| 宝清县| 永康市|