How to save image or any others file type directly from file in SQL Server with binary format

sql2008

USE Arm_DB
GO

IF OBJECT_ID('TBL_Image','U') IS NOT NULL
 DROP TABLE TBL_Image

 CREATE TABLE TBL_Image 
  (
  [ID] INT IDENTITY(1,1)
 ,[Image] VARBINARY(MAX)
   CONSTRAINT PK_TBL_Image PRIMARY KEY CLUSTERED (ID) 
  )
Go
INSERT INTO TBL_Image(Image)
SELECT * FROM OPENROWSET(BULK 'C:\Users\Public\Pictures\Sample Pictures\Koala.JPG',SINGLE_BLOB  ) i
Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s