How Do You Save An Image Out of a SQL Database Into the File System Using only SQL? - sql

Similar to this question only the other way of flow.
Insert Picture into SQL Server 2005 Image Field using only SQL
I need to be able to save a image field out into the file system and be able to name the file with only using SQL. I don't want to use TEXTCOPY either because I need to use the connection to the database that is running the query itself.
I'd like this to work in SQL 2005 to support older database clients but if it's available in only 2008 that's fine.
Any ideas?

With SQL 2k8 there is the new FILESTREAM type that covers such cases. Filestreams can be opened via the Win32 file access handle like any other file, but hey are integrated into the database from transaction and backup/restore point of view.
I had a similar issue in SQL 2k5 and my solution was to use a CLR stored procedure with EXTERNAL_ACCESS that was writing into the file system using C# file operations.

I don't believe there is a way to save out using only sql, but there is a command-line utility, bcp.

Related

Is there a simple way to upload a Tab delimited file to SQL Server without using BCP?

After using BCP for a year and fooling around with character encoding (x-UTF-16LE-BOM? Really?) we want a better solution. I have worked with Oracle and it is as simple as selecting a table and uploading the file.
Is there anything that can do that with SQL Server?
BCP must use x-UTF-16LE-BOM or it chokes.
BULK INSERT requires the file to be on the SQL Server instance (really?)
I have Microsoft SQL Server Management Studio but it doesn't seem able to do it.
Any help? We are in the Azure Cloud and I want it simple!

TSQL in Windows phone 7

I'm porting an app from iPhone to Windows phone 7. The server sends an SQL file (T-SQL queries) with all info. Is there a way to execute these commands inside the SQL CE?
I can parse the sql file as its a flat text file, but I wonder if the sql ce can do it automatically?
There is no direct SQL access in Windows Phone, the only way is to use Linq to SQL!
All database access in Windows Phone is based on generated data models that make tables and their rows into collections of objects.
You can't even call a method to execute an SQL command, like you would in the desktop with ExecuteNonQuery()
So, seems to me that the only way you will be able to work this out is if you just send the whole SQL Compact database file (*.sdf), save it to the Isolated Storage, and then access it with Linq to SQL, or you'll have to write some code to parse your SQL file...

update database table from csv file remotely

I have been asked by a client of mine if it would be possible for their warehouse to send a csv file of their stock to our server which then updates our sql server database automatically with the csv content. Aparently their sage system does this but im not sure if i can do it with standard sql server management studio 2008 i have on my server?
There are two ways that I use to do such tasks:-
Build an SSIS package to open/parse/import the data.
Use the OPENROWSET function. If the filename of the CSV is always the same, then it makes this option simpler.

Importing Multivalue DB with SSIS into SQL

I would like to know if it is possible to Transfer Data into SQL Server from a multi value database file using SSIS.
The only thing that I could find online was using a bluefinity tool to achieve this.
Thanks
Simona
I have done this from Universe, but Universe has an ODBC driver that allows the datavase to be viewed as if they were tables. Almost like SQL views.
SSIS can import from almost anything that you can get either a .Net, ODBC, or OLE DB driver for. There has to be someway to talk to the DB from an extrnal program, though.
I suspect that you has no driver (ODBC,OLEDB,.NET). So you can use C# script (even from SSIS) and extract data to flat file and then to SQL Server or do it directly to SQL Server.

Importing data to MySQL from MS SQL

I want to import data from MS SQL Server, run it through some sort of regexp to filter out stuff, and import it into MySQL. I then, for each query, wish to display a relevant image from a third database. What would be the easiest way to do this, importing and linking wise?
Thank you.
Clarification: It is a php application to filter data from another database, and then for each record show an associated image from a 3rd database. It is from scratch...
You can try the MySQL Migration Toolkit.
http://dev.mysql.com/downloads/gui-tools/5.0.html
Now archived at http://downloads.mysql.com/archives.php?p=mysql-migration-toolkit
use SQL Management Studio (or Enterprise Manager depending on version) with the SQL Server import wizerd to get it into MS SQL.
From there you can export it to Mysql using the MySQL connector drivers.
As for as displaying an image from a third database, that is completely up to the code you have written in your application.
I would use the Microsoft SQL Server Data Publishing Wizard (free). You can use it to script your entire database (including insert statements.) You'll have to edit this script a little bit probably to get it to run in MySQL. Now you just have a regex problem. You can try:
Manipulating the data in MS SQL via a query, or from code (using regex) the transfer.
Running your regexes on the script file itself, maybe try some macros, find and replace, etc.
Manipulating the data in MySQL via a query, or from code (using regex) after the transfer.