sql >> Databasteknik >  >> RDS >> Sqlserver

Infoga bild i SQL Server 2008 Express-databas utan gränssnittsapplikation

Det kommer att fungera för SQL Server 2008r2...men först måste du skapa en filströmsdatabas.

//skapa databas

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

//tabellskapande

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

//infoga värde

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. Returnera kolumnvärden före UPPDATERING endast med SQL

  2. sqlite rad-ID matchar inte listvy - ANDROID

  3. DELETE rekursiv PostgreSQL

  4. Oracle 'printf' motsvarighet