DATETIME SELECT SELECT INTO DATE PAD STRING DYNAMIC SQL CURSOR MONEY FORMAT PERCENT STORED PROCEDURE SQL SERVER AGENT JOB OPTIMIZATION WHILE LOOP OVER PARTITION BY UPDATE
 
 
SITE SEARCH SQLUSA.com VIDEOS
 
 
SQL E/BOOKS   WORLD, USA & SQL NEWS   FORMAT
SCRIPTS SQL 2005 SQL 2008 ARTICLES
How to import an image into a table?

This is not a simple operation. First you create an image table.

create table ClassicImage ([picture] image)

Second you setup a format file using bcp at command prompt. You have to respond to the prompts. You set the size of image the size of the image file you are about to import. You save the format file with name: e:\data\test\pubsimage.fmt

bcp pubs..classicimage out e:\data\test\classicimage1.dat -SPROD1 -Usa -P

Finally, you are ready to import in Query Analyzer:

use pubs

 

BULK INSERT ClassicImage FROM 'e:\design\photos\mydog1.jpg'

WITH (FORMATFILE = 'e:\data\test\pubsimage.fmt')

 

-- SQL Server 2005 and on - BLOB upload to database

UPDATE dbo.CatalogImage

SET    LargePhoto = (SELECT *

                FROM   OPENROWSET(BULK 'F:\image\manhattan.JPG',

                       SINGLE_BLOB) AS x)

WHERE  [ImageName] = 'MANHATTAN.JPG'

GO

 

Exam Prep 70-461
SQL 2016 DESIGN & PROGRAMMING
 
 
 
DATETIME SELECT SELECT INTO DATE PAD STRING DYNAMIC SQL CURSOR MONEY FORMAT PERCENT STORED PROCEDURE SQL SERVER AGENT JOB OPTIMIZATION WHILE LOOP OVER PARTITION BY UPDATE