Showing posts with label word. Show all posts
Showing posts with label word. Show all posts

Monday, March 19, 2012

How to import word documents into SQL Server

Hi All,

I need to import multiple word documents of same structure into SQL Server table. Could anyone suggest the way of doing this?

Thanks,

What do you mean, "the same structure"? Do you want to extract informaiton from the documents or just store each one as a BLOB? If the latter, the 'Import Column' component should work for you.

-Jamie

|||I mean i want to extract information from word documents into sql server tables.|||

Hemal Shah wrote:

I mean i want to extract information from word documents into sql server tables.

I'm not sure really. This isn't a common request seeing as Word documents are not structured files. The normal answer to extracting unstructured data using SSIS is that you're going to have to use code. You can download Primary Interop Assemblies for Office that enable you to interact with Word documents using dotnet code - hence you can use them in a script task/component.

-Jamie

How to import word document to sql server?

How can I import my word documents into SQL server 2000?> 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/mi...>
7e3782e59a93
database=>stream
http://groups.google.co.uk/group/mi...>
73f1db2951f1
Marc|||Thank you very much Ian & Marc, it was helpful and I really appriciate it
"Raghad" wrote:

> How can I import my word documents into SQL server 2000?|||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/

How to import word document to sql server?

How can I import my word documents into SQL server 2000?
> 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/