There is a xml file in www.samplexxxxx.com/myfile.xml
I want to read or query this file with SQL Server in my computer
Can I make this?
Here is one example: http://pratchev.blogspot.com/2008/11/import-xml-file-to-sql-table.html
Also see dba.stackexchange.com for another option
Quite a bit of manual work. It's a bit of a square peg in a round hole, DBMS systems aren't great at working with XML data. I would recommend parsing the XML using Java, PHP, python, whatever...and inserting the data into a DBMS if needed.
Related
How can you decompress an sql server field with nothing but tsql queries?
Assumptions:
The field was compressed using GZIP from an application.
The field is a varbinary(max).
MSSQL version is less than 2016, meaning you can't use decompress function.
I don't think this is possible, I tried searching on google and found nothing. I'd like to have confirmation on this.
I think your best bet is to look into a CLR solution. CLR functions are written in C# and then can be executed in a standard SQL call. There are loads of examples on the internet of CLR functions.
My answer assumes you have purely SQL Server and not a solution like SSIS or alike installed.
Here's a link for basic example. You'll load a library that handles gzips. Lots of solution directions here.
https://www.skylinetechnologies.com/Blog/Skyline-Blog/March-2013/CLR-Functions-in-SQL-Server-A-Tutorial
I would like to know if anyone has a good solution for importing BAIv2 banking files into SQL Server. First of all the files have "continuation records" which have to be considered along with the parent records. Also, T-SQL doesn't have a pleasant way of parsing comma-separated strings. Finally, one hierarchy in the file has a varying number of elements so that makes direct pasting into a table difficult because the columns would not line up.
This is the file from hell. If anyone has any insights into how to import and parse BAIv2 banking files I would be most appreciative.
Thank you,
You're best off handling this with a dedicated application server and a real (general-purpose) programming language. T-SQL is ill-suited for this task.
When that's not an option, you can use C# for a SQL CLR stored procedure to parse the files. I did something similar for banking flat-files when I didn't have the option of an application server.
Is there an equivalent of Microsoft .Net's SQLXML Bulk Load (http://msdn.microsoft.com/en-us/library/ms171878.aspx) for Postgresql/PostGIS that I can run on linux? I have a huge and complicated XML file I'd like to import into PostGIS on a linux server without having to write a ton of code to shred the XML. I already have the XSD for it (this one: http://www.dft.gov.uk/transxchange/schema/schemas.htm) so I was hoping I could just specify the relations in the XSD (eg sql:key-fields="ProductID") and set it going.
If there isn't what's the next best thing to import it if I don't want to have to spend weeks writing code to convert XML into tables?
I am not aware of any utility, but I wonder if this is because, for the most of the open source weakly typed languages have good XML file parsers you could use to just pull it into a giant data structure and process it however you like.
So assuming you don't have files that are are huge, my recommendation would be something like Perl, DBI, and XML::Simple.
I have a need to record XML fragments in a SQL Server 2005 database for logging purposes (SOAP messages, in this case). Is there any reason to use the XML datatype over a simple varchar or nvarchar column?
I can see instances already where being able to use XPath to get into the data in the XML would be rather nice, and I haven't been able to find any real downsides in some brief research.
Are there any pitfalls that need to be watched out for or is there a better way to approach this?
Here's a great forum post on the topic. In general, use XML datatypes if you forsee needing the XML manipulation and typing functionality.
Depending upon the size of xml and the ability of extracting particular information from within the xml, it can become a drawback. Did you consider storing the xml on the file system and just having the path in the database?
The only problem we have encountered is that writing queries against the data is more difficult.
In some cases we have stored data in XML and later dumped it into tables for reporting.
Is there any framework for querying XML SQL Syntax, I seriously tire of iterating through node lists.
Or is this just wishful thinking (if not idiotic) and certainly not possible since XML isn't a relational database?
XQuery and XPath... XQuery is more what you are looking for if a SQL structure is desirable.
You could try LINQ to XML, but it's not language agnostic.
.Net Framework provides LINQ to do this or you can use the .Net System.Data namespace to load data from XML files.
You can even create queries that have joins among the tables, etc.
For example, System.Data.DataTable provides a ReadXml() method.
XQuery is a functional language that is closest to SQL. XPath is a notation for locating a node within the document that is used as part of XSLT and XQuery.
XML databases such as MarkLogic serve as XQuery engines for XML data, much as relational databases serve as SQL engines for relational data.
That depends on the problem you are solving. If XML file is pretty large, sometimes it's a necessity to use something like SAX parsers to traverse the file node by node, or you will get OutOfMemoryException or will run out even of virtual memory on your computer.
But, if the expected size of XML file is relatively small, you can simply use something like Linq, also see my answer - here I tried to explain, how to make traversing through nodes much easier with constructions like yield return.
SQL Server 2005 supports XML DML on it's native xml data type.
XQuery is certainly the way forward. This is what is used by XML databases like eXist and MarkLogic.
In the Java world there are several solutions for running XQuery on flat files, most notably Saxon
For .NET, there is not so much available. Microsoft did have an XQuery library, although this was pulled from .NET 2 and has never resurfaced. XQSharp is a native .NET alternative, although currently only a command line version has been released.