sql >> Database teknologi >  >> RDS >> Sqlserver

Indsæt billede i SQL Server 2008 Express-database uden frontend-applikation

Det vil virke for SQL server 2008r2...men først skal du oprette en filstream-database.

//opret database

CREATE DATABASE Archive 
ON
PRIMARY ( NAME = Arch1,FILENAME = 'c:\data\archdat1.mdf'),
FILEGROUP FileStreamGroup1 CONTAINS FILESTREAM( NAME = Arch3,FILENAME = 'c:\data\filestream1')
LOG ON  ( NAME = Archlog1,FILENAME = 'c:\data\archlog1.ldf')
GO

//tabeloprettelse

Use Archive
GO
CREATE TABLE [FileStreamDataStorage]
(
[ID] [INT] IDENTITY(1,1) NOT NULL,
[FileStreamData] VARBINARY(MAX) FILESTREAM NULL,
[FileStreamDataGUID] UNIQUEIDENTIFIER ROWGUIDCOL NOT NULL UNIQUE DEFAULT NEWSEQUENTIALID(),
[DateTime] DATETIME DEFAULT GETDATE()
)
ON [PRIMARY]
FILESTREAM_ON FileStreamGroup1
GO

//indsættelse af værdi

Use Archive
GO
INSERT INTO [FileStreamDataStorage] (FileStreamData)
SELECT * FROM
OPENROWSET(BULK N'C:\Users\Public\Pictures\Sample Pictures\image1.jpg' ,SINGLE_BLOB) AS Document
GO


  1. mysql match streng med start af streng i tabel

  2. Sammenligning af datoer i Oracle SQL

  3. Sådan behandles 0000-00-00-datoen i jdbc MySQL-forespørgsel

  4. java enum og postgresql enum