> How can I import my word documents into SQL server 2000?
i assume what you want is to insert them into a table?
You're going to want to create a table with a column of type "image", which
is a BLOB field (Binary Large OBject).
Then you'll want to read the documentation on your database access
technology (ADO, OLEdb, ODBC, Hibernate, etc) on how to insert blobs into a
table.
|||Futher to Ian's post, some ADO.NET examples (in c#):
stream=>database
http://groups.google.co.uk/group/microsoft.public.dotnet.languages.csharp/msg/314e7e3782e59a93
database=>stream
http://groups.google.co.uk/group/microsoft.public.dotnet.languages.csharp/msg/fcd173f1db2951f1
Marc
|||This works in MSSQL 2005 (untested in 2000). It assumes that the file is
accessible by the server (on one of its local disks, or a network shared
drive). This example updates an existing record, but you could do something
similar with an insert. I do it this way because I don't have the photo yet
when I first create the record.
CREATE TABLE [dbo].[COURSES](
[COURSEID] [int] PRIMARY KEY IDENTITY(1,1) NOT NULL,
[COURSENAME] [nvarchar](40) NOT NULL,
[MAP] [varbinary](max) NULL
)
GO
create procedure spInsertPhoto
@.inCourseID int,
@.inPhotoFileName nvarchar(100)
AS
declare @.SQL nvarchar(1000)
set @.SQL =
'UPDATE COURSES
SET MAP = (
SELECT Photo.*
FROM OPENROWSET
(BULK '+ QUOTENAME(@.inPhotoFileName, '''') + ' , SINGLE_BLOB) Photo)
WHERE courseid = ' + cast(@.inCourseID as varchar)
exec (@.SQL)
GO
insert into COURSES
values('Test Course', NULL)
GO
exec spInsertPhoto 1, 'c:\temp\test2.jpg'
Alain Quesnel
alainsansspam@.logiquel.com
www.logiquel.com
"Raghad" <Raghad@.discussions.microsoft.com> wrote in message
news:52A8884D-4DAD-4713-AC71-67ACAC99A993@.microsoft.com...
> How can I import my word documents into SQL server 2000?
|||AQ> This works in MSSQL 2005 (untested in 2000). It assumes that the
AQ> file is accessible by the server (on one of its local disks, or a
AQ> network shared drive).
The bulk provider isn't support for OpenRowSet in 2000.

Thanks,
Kent Tegels
http://staff.develop.com/ktegels/
No comments:
Post a Comment