Solved

varbinary(max) filestream - how to insert/reference file location?

Posted on 2011-09-02
4
466 Views
Last Modified: 2012-05-12
I have the below table - when I use the below insert - and then set a full text index - it is apparent, it is just storing the file name or something as when I check the indexed words - only the document name is indexed - so my question is - when trying to use filestream and varbinary(max) - is the simple example below correct?

CREATE TABLE cptDocuments(
  [docID] [int] IDENTITY(1,1) NOT NULL,
  [document] varbinary(max) FILESTREAM NULL,
  [docExtension] varchar(30),
  [RowGuid] UNIQUEIDENTIFIER NOT NULL  ROWGUIDCOL UNIQUE DEFAULT NEWID(),
CONSTRAINT [PK_cptDocuments_docID] PRIMARY KEY CLUSTERED
(
  [docID] ASC
) WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO

INSERT INTO cptDocuments(Document, [docExtension]  )
VALUES (
CAST('C:\inetpub\wwwroot\PDE\CPTAssistant\Archives\Updated Reporting Instruction for Hydration Infusion (Code 90760).htm' as varbinary(max))
,'.htm'
)
0
Comment
Question by:tbaseflug
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 3

Expert Comment

by:tknudsen-qec
ID: 36475072
Short answer, no.  

INSERT INTO cptDocuments(Document)
    SELECT *
    FROM OpenRowSet(BULK N'C:\inetpub\wwwroot\PDE\CPT....', SINGLE_BLOB) AS Document

You can also drop it into a variable thusly:

DECLARE @mybinary VARBINARY(MAX)
SELECT @mybinary = BulkColumn
FROM OPENROWSET(BULK N'C:\inetpub\wwwroot\PDE\CPT....', SINGLE_BLOB) AS Document

And then insert that.

HTH
0
 

Author Comment

by:tbaseflug
ID: 36475090
is there a way - say after I do that or during that - to put in a few other variables - such as 'file name here.htm' and '.htm' - the file name and the extension - as part of that insert statement in openrowset?
0
 
LVL 3

Accepted Solution

by:
tknudsen-qec earned 500 total points
ID: 36475127
Absolutely.  Its particularly clear with the second example, since you can insert your extensions PLUS the variable:

INSERT INTO MyTable (ExtensionColumn, BinaryColumn) VALUES ('.htm', @myBinary)


But with the first example, that "SELECT *" only returns one column (BulkColumn).  You could also:
"SELECT *, '.htm' as extension"
if you like.  

If I'd been using both my braincells I would have used BulkColumn in both examples.
0
 

Author Closing Comment

by:tbaseflug
ID: 36475191
Thanks!
0

Featured Post

Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article I will describe the Backup & Restore method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
In this article I will describe the Copy Database Wizard method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…

631 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question