USE AdventureWorks
-- export
DECLARE @SQLcommand nvarchar(4000)
SET @SQLcommand = 'bcp "select LargePhoto from AdventureWorks.Production.ProductPhoto where ProductPhotoID = 111" queryout "C:\Documents and Settings\All Users\Documents\My Pictures\Sample Pictures\Blue hills.jpg" -T -n '
EXEC xp_cmdshell @SQLcommand
GO
-- import image
INSERT Production.ProductPhoto (
ThumbNailPhoto,
ThumbnailPhotoFileName,
LargePhoto,
LargePhotoFileName)
SELECT null, null, LargePhoto.*, N'Blue hills.jpg'
FROM OPENROWSET
(BULK 'C:\Documents and Settings\All Users\Documents\My Pictures\Sample Pictures\Blue hills.jpg', SINGLE_BLOB) LargePhoto
GO
select * from Production.ProductPhoto order by ModifiedDate desc
GO
No comments:
Post a Comment