Showing posts with label doc. Show all posts
Showing posts with label doc. Show all posts

Wednesday, March 7, 2012

File storage with SQL server

Hello,

i'm thinkink about design of a new WinApp.

In this app, i need to store files (xls, doc and pdf essentialy), i need to be able to open and modify it.

I want to use SQL Server 2005 to store those file to be able to use replication process.

Is it possible, is it a good idea ?

Thanks a lot

yes its possible and in most cases prefered. you would store them in an image field.

programmatically, your app would open the file via a stream and read the file to a byte array. You would then use a parameterized a parameterized query to write the bytes to the array.

http://support.microsoft.com/default.aspx/kb/317016/EN-US/

|||Thank you very much for this answer !|||I wont slag you for your inglish if you dont slag me for my typink

Friday, February 24, 2012

File name with sp_xml_preparedocument - Not working ?

Is it legal to give filename to sp_xml_preparedocument

Can i do

DECLARE @.hdoc int DECLARE @.doc varchar(1000) SET @.doc ='C:/XML/myXmlFile.xml' --Create an internal representation of the XML document. EXEC sp_xml_preparedocument @.hdoc OUTPUT, @.doc -- Remove the internal representation. exec sp_xml_removedocument @.hdoc

I know the XML is well formed because when the paste the file in @.doc above it worksI tried doing it and i get the following error: The XML parse error 0xc00ce556 occurred on line number 1, near the XML text "C:\XML_Processing\Test.xml".Msg 6602, Level 16, State 2, Procedure sp_xml_preparedocument, Line 1The error description is 'Invalid at the top level of the document.'.Msg 6607, Level 16, State 3, Procedure sp_xml_removedocument, Line 1sp_xml_removedocument: The value supplied for parameter number 1 is invalid. The XML is :<ROOT>
<Customer CustomerID="VINET" ContactName="Paul Henriot">
<Order CustomerID="VINET" EmployeeID="5" OrderDate="1996-07-04T00:00:00">
<OrderDetail OrderID="10248" ProductID="11" Quantity="12"/>
<OrderDetail OrderID="10248" ProductID="42" Quantity="10"/>
</Order>
</Customer>
<Customer CustomerID="LILAS" ContactName="Carlos Gonzlez">
<Order CustomerID="LILAS" EmployeeID="3" OrderDate="1996-08-16T00:00:00">
<OrderDetail OrderID="10283" ProductID="72" Quantity="3"/>
</Order>
</Customer>
</ROOT>

Hemanshu:

I think the argument to the sp_xml_preparedocument stored procedure is that actual XML text and NOT a file reference. Please give a look to the SP_XML_PREPAREDOCUMENT stored procedure in books online.

You might be able to do something like:

Code Snippet

select * from openrowset( BULK 'C:/XML/myXmlFile.xml' SINGLE_BLOB)

to fetch the data. Give a look to OPENROWSET in books online.