zoukankan      html  css  js  c++  java
  • 导出northwind中Employees的图像.sql

    --用下面的方法导出就可以保证导出标准的图片文件

    declare @id int,@fn nvarchar(260),@tmpfn nvarchar(260)
    select @id=2                --要导出的employeeid
        ,@fn='c:\test.bmp'        --导出生成的文件名
        ,@tmpfn='c:\tmp.bak'    --导出过程中使用的临时文件名

    --生成临时表,控制取消图片数据中的前缀
    create table ##tb(img image)
    insert into ##tb
    select photo from northwind..Employees where employeeid=@id

    --删除前缀处理
    declare @p varbinary(16)
    select @p=textptr(img) from ##tb
    updatetext ##tb.img @p 0 78 null

    --导出数据
    declare @sql varchar(8000)
    set @sql='bcp "select * from(select null as 类型 union all select 0 as 前缀 union all select 0 as 长度 union all select null as 结束 union all select null as 格式) a" queryout "'
        +@tmpfn+'" /c /S"zj" /P""'
    exec master..xp_cmdshell @sql,no_output

    set @sql='bcp ##tb out "'+@fn+'" /S"zj" /P"" /i"'+@tmpfn+'"'
    exec master..xp_cmdshell @sql,no_output

    set @sql='del '+@tmpfn
    exec master..xp_cmdshell @sql,no_output
    go
    drop table ##tb
  • 相关阅读:
    2016/11/2
    2016/11/1
    bzoj 3809: Gty的二逼妹子序列
    bzoj 1207: [HNOI2004]打鼹鼠
    bzoj 1191: [HNOI2006]超级英雄Hero
    BZOJ 1854: [Scoi2010]游戏
    BZOJ 1296: [SCOI2009]粉刷匠
    BZOJ 1787: [Ahoi2008]Meet 紧急集合
    tarjan算法
    高级的暴力(一)——分块
  • 原文地址:https://www.cnblogs.com/shihao/p/2532721.html
Copyright © 2011-2022 走看看