在SQL Server 2005中有一些新的資料型別取代了原本在SQL Server 2000
上的大量資料的資料型別:
上的大量資料的資料型別:
- text --> varchar(max)
- ntext --> nvarchar(max)
- image-->varbinary(max)
- varbinary-->udt
- ntext-->xml
所以在T-SQL中,我們可以利用下列的範例,把image儲存到SQL Server 2005中
USE AdventureWorks;
GO
UPDATE Production.ProductPhoto
SET ThumbNailPhoto = (
SELECT *
FROM OPENROWSET(BULK 'c:/Tires.jpg',
SINGLE_BLOB)AS x )
WHERE ProductPhotoID = 1;
GO
在SQL Server 2005所提供的範例資料庫(AdventureWorks),
其中Production.ProductPhoto表格的ThumbNailPhoto欄位是
varbinary(max),亦即代表SQL Server 2000中的image資料型別。
這段語法,使用OPENROWSET function中的BULK選項,將image圖檔
載入到欄位中,所以需要在語法中詳細指明圖檔在磁碟機的路徑及檔名。
转自:http://dotnetframework.blogspot.com/2006/08/sql-servrentext-textimage.html