J'essaie de comprendre comment insérer un fichier .jpg dans un champ de base de données SQL Server 2000 de type image à l'aide de SQL transact. Merci. P>
3 Réponses :
Utilisez OpenRowset: CREATE TABLE MyTable
(
ID INT PRIMARY KEY IDENTITY (1,1),
ImageColumnName IMAGE NULL
)
GO
-- must insert a dummy value into the image column for TEXTPTR
-- to work in next bit
DECLARE @RowId INT
INSERT MyTable (ImageColumnName) VALUES (0xFFFFFFFF)
SELECT @RowId = SCOPE_IDENTITY()
-- get a pointer value to the row+column you want to
-- write the image to
DECLARE @Pointer_Value varbinary(16)
SELECT @Pointer_Value = TEXTPTR(ImageColumnName)
FROM MyTable
WHERE Id = @RowId
-- write the image to the row+column pointer
WRITETEXT MyTable.ImageColumnName @Pointer_Value 'c:\myjpeg.jpg'
C'est ce que j'ai essayé de faire, mais je pense que la syntaxe SQL Server 2005 ne semble pas fonctionner en 2000
Il y a un outil appelé textcopy.exe Vous pouvez le trouver sous MSSQL \ Binn ou l'obtenir avec SQL Server 2000 SP4 P>
Alexander Chigrik a écrit une belle procédure stockée pour Usinig It avec la requête SQL: P>
http://www.msqlcity.com/articles/knowhow/textcopy.htm < / a> p>
La procédure stockée trouvée dans ce tutoriel a fonctionné pour moi: p>