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
Related
I have a question in regards to the SQLXML for SQL Server.
My assignment is to convert an XSD file so that it magically "becomes" tables in the SQL Server database. I've looked around everywhere, on all the links I could possibly find, but nothing clicks. Everything is like a half-step of what I need to achieve.
I am not too familiar with Visual Studio, haven't done much else than running database queries and all the stuff one likes to do in a SQL Server database. Except for XML.
I figured that SQLXML from Microsoft's MSDN would be a good tool to have (and I believe it's already installed).
Any tips or solutions?
Thanks.
There's no magic involved, and as it's homework/study I won't detail how to do it myself, but if you direct your research towards SQL's Bulk Load functionality it would seem to be what you need.
Read this article for a brief "how to" guide.
Or this article for a detailed description of how to use it.
You can convert XSD to SQL using this approach https://github.com/ujhgj/xsd2sql
But I'm not sure of SQL dialect. That thing worked for Mysql.
Does anyone know where I can get SQL server documentation pertaining to writing stored procedures (SQL Server 2008 R2)?
I Tried browsing SQL Server 2000 Books Online but find it very hard to use with links scattered all over the place.
I am particularly interested with built in functions (T-SQL), that includes examples, maybe in a pdf form also ?
Here is a list of built-in functions on MSDN. Get used to using MSDN; it's a great reference but you have to learn its quirks.
Here is a good article about stored procedures, i guess it will give you some useful info.
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.
So I am importing some images stored in SQL image columns, and I need to change them to Byte arrays since I store my images as varbinary(max) and recreate them. I would LOVE it if there was a program to do this, or a really easy way since I don't have a ton of time.
Any ideas out there?
The image data type in Sql Server is a varbinary field that is being discontinued in future versions.
I would bet that a tool like bcp handles the "conversion" automatically. I use quotes because its a type conversion and not a format conversion.
Have you looked into writing a quick script in PowerShell? It has access to the full .NET framework, so should be somewhat simple if you're using those technologies.
Of course it's not simple if you have to learn PowerShell in order to write the script, but learning's always good :)
For smaller websites which are view-only or require light online-editing, SQL Server 2008, Oracle, and MySQL are overkill.
In the PHP world, I used SQLite quite a bit which is a e.g. 100K file holding hundreds of records which you speak to with standard SQL.
In the .NET world, what options do we have, I've seen:
SQL Server 2008 Express (free but the files are bloated 2-10MB with just a couple records)
SQL Server Compact 3.5 (seems interesting)
Vista.db (not free?)
What about SQLite with .NET, have any of you had success with that?
Any other small, no-nonsense, SQL databases for .NET there?
I would particularly be interested in something like SQLite but that supports CLR type system and LINQ.
Maybe this Wikipedia RDBMS comparison might help you in making your choice.
SQLite works just fine with .NET.
I second Edoode's suggestion of Firebird - that works great for me.
Be very careful when using SQL Server CE in multi-threaded applications.
I had to use Interbase at work, so I came to Firebird.
First I had to use it, now I love it.
There's a .NET Data Provider (ADO, DDEX).
U can even use it without setting up a server, like you do with SQLite (direct access to the database file).
It's actively developed and "open source".
I don't think there is any database that supports the CLR type system, even SQL server uses their own types.
Besides the already mentioned alternatives there is also Firebird
You can also have a look at db4o which is not SQL but a fully managed object store for java and .NET.