Sql Server FileStream: Architecture for document and image - sql-server

In my project i want use sql server filestream for file document like pdf,docx, excel, and also for image file.
In generally for file document i use a single table.
My question is for image i have to use another table or it's ok to use the same table?
Thank!

If you want to store your files with filestream, you can use a single table for that.
I don't see any conditions for having multiple tables for different file types in your question.

Related

SQL Server (Transact-SQL) difference between Filestream and BLOB

Could anyone explain in laymans terms, what is the difference between those two data types and moreso, which are the pros and cons of using either of those to store files in a database.
If context is needed then I am creating a web app, where users can upload a multitude of different data, like images, Excel files, .docx etc.
Blobs are stored in a varbinary(MAX) column with the value stored in data pages inside the database data file(s).
With FILESTREAM, values are stored as individual files separately on the filesystem, with an individual file for each row and value. These files are managed internally by SQL Server and can be stored and retrieved using T-SQL just like normal varbinary(MAX) values or with Win32 APIs.
There are also FileTables, which is a specialized table with a predefined schema on top of FILESTREAM. FileTables provide T-SQL access like blobs and FILESTREAM and can optionally be access via a SQL Server managed UNC path, similarly to a normal Windows share. Creating/deleing files via the share inserts/deletes rows from the file table and visa-versa.

Is it possible to feed a database table from a XML file?

We have some (stable) data that is saved in some generic database (database that contains a database structure and its data). To be used, this data must be re-written. Currently, we have an application that export this data to XML files to some very specific location.
We need to add this data to some databases. I know it's possible to load XML inside tables, but we'd like a direct link between the XML files and the database tables (reducing data duplication and risk of seeing people update the generated tables instead of using proper methods).
Is that possible?
Would it be very slow?
You can use SSIS to import XML files into database tables. This will work well if the xml files conform to a schema.
https://www.mssqltips.com/sqlservertip/3141/importing-xml-documents-using-sql-server-integration-services/

Extract data from thousands of Excel files into database

We use SharePoint 2013 as a library to hold thousands of Excel files, with almost never consistent formatting, to manage projects occurring on servers. Somewhere in these maybe formatted as table objects is a common set of server names.
Somehow, without being able to change this process in the short term, I need to pull data from all these files to identify how many projects are targeting a particular server.
I've got access to SQL Server 2016 enterprise, and wondering if something like PolyBase could help with this? I also wonder about SSIS but I don't expect any tables to look exactly like another one.
Other tools may be an option, but I'm not sure what can handle this scale and variety. I think daily updates to the data would be enough, but even so it's still a mess.
How do I pull thousands of varied excel tables into a database? Is this even possible?
Any longer term solution that doesn't allow them to format and annotate like excel is unlikely to actually be adopted.
The less you know in advance, the more difficult it will be...
Some ideas:
Technology
read about FROM OPENROWSET which allows to read from an Excel
read about linked server
Use Excel and its great abilities through VBA to iterate through all your Excel-Sheets, open them, analyse them and fill proper tables. Within Excel you know most about your messy data...
Target structure
You might create thousands of tables, each representing one single sheet in all your Excel files. You could query these tables with dynamically created SQL (using meta-data of INFORMATION_SCHEMA) or think about Full-Text-Search
You might import each sheet into one single XML-structure (SELECT * ... FOR XML PATH('...')). In this case you'd need a target table with columns for Path and name of your Excel, Name of the sheet and an XML column for your data. Another approach was to represent each File on one XML and include all sheets there. Try to define common naming for all your data. Querying XML allows to query columns without knowing their actual names (XQuery with XPath using *).
If your Excels are xlsx already, you might open them with UNZIP and take the existing XML as-is.
To be honest: I do not think that any tool can do the magic to import such a wide range of mess automatically...

how to convert two different tables data into one single .csv file in oracle appex

I have two tables in database. I want to create a .csv file to maintain all activities done on that two tables. I need help in converting these two tables data into one single .csv file in oracle apex.
Are you just trying to export the data to a CSV?
write an SQL select query to link both the tables together. If you need help with this, let us know
create a Report and enter the SQL in the source
go to Report Attributes, there is an option called Enable CSV Output. Make sure this is set to Yes
Run the page, there should be a hyperlink or button beneath the report which exports the file.

SQL Server - retrieving stored files from DB to filesystem

In SQL Server database we have files stored in a table.
We want to extract files from DB to filesystem
The files are html, xls, pdf, image formats.
Please advise options to retrieve information with minimum programming effort.
Can this be done directly from database using some SQL function / TSQL code?
Can this be done by ASP.net?
Can we export records as XML file and work on the attachments?
Thanks.
If data is stored as BLOB, then you can simply query that column like any other column in SQL Server. And if you are using Filestream to store files into file system, then this MSDN Magazine article should help you.

Resources