Procedure to export/import xml file on selected path - sql

I looking for how to export and import generated from table xml file to a selected path. Path to the file is must be as parameter becouse user in C# program will send path to save it on disk. I do little research and found this but it's don't saying very much to me. Here is link: https://www.mssqltips.com/sqlservertip/4963/simple-image-import-and-export-using-tsql-for-sql-server/
I don't use sql server too much and that's why im here

Related

export files (pdf etc) from MS SQL image data type to filesystem

I want to export Data, several filetypes, .jpg, .pdf, .msg, .doc, etc into Windows filesystem.
The data is unfortunately stored in a image data type column.
After exporting it gives me an error "file corrupted or filetype not supported, e.g not correct decoded".
I tried to export with an c# 20line script, and with that sql script: https://stackoverflow.com/a/9127325/1650038
but both unsuccessful.
Any ideas how to export the files? Doesn't matter with what technology, c#, sql etc . New location will be an oracle DB..
I don't now the reason but BCP is not working fine with exporting files and images.
The Best Way to export files from SQL is to Create a DotNet application, Loading them in a DataSet and Export them to files . There a lot of articles showing how to do it.
Example 1
Example 2
But for TSQL :
Try the solution writen in this Topic
And for additional information read this Topic and read the comments at the bottom of the correct answer. We have made a lot of workarounds.

what format is most reliable for saving a history file from an application?

Good Afternoon,
I am in the process of developing in vb.net a simple “cheque printing” application which will allow users to fill in a few text boxes with the values that will be printed on a cheque.
When they hit the print button, the values will be sent to the printer, but I also want the values they input in the text boxes saved to a file, so like a history file of all the cheques that were created.
I am thinking to use either an access database or an excel spreadsheet as my history file, but I am not quite sure on which would be best.
Please note that in my environment storing this information in a SQL database is not an option and also this file will most likely be stored/accessed from the network.
The history file needs to be:
1.Stable (cannot corrupt easy)
2.Reliable
3.Easily exportable in case we need to export the information to one of our in-house systems.
4.editable from the application I am developing
Kindly advise,
A
XML. Save the data to DataTable object and then use the .WriteXML method to save it as an xml file. I'd advise creating a strongly-typed DataTable class for this, so that the XML can be exported with a reliable schema and imported easily.
If you are using different fonts, you could use a .rtf (rich text format) which will save the format of the text that you send to print... it is a universal file format, you can open it with open office, ms office, or any office suite you have...
Access will be best choice,
it's relational database and can make a form from this file to do what are you looking for without VB or any code.
Also you can access this file from network.
for more detail about setting for this file go to this link
http://goo.gl/bOfGp6
and you will find more options complete your work.
I would use a MySQL server. It's free.
XML is also good, but I hate sharing folders...

Export database from SQL Server Management Studio

I've managed to 'Restore' my database using the SQL Server Management Studio.
I now need to export that so I can import it into my websites empty database.
I've tried Tasks/Generate Scripts but I can't import the file it generates into my database on my site.
I get the following error message:
Could not find stored procedure 'xxx'
I've also tried to Export Data but I don't appear to get a result at the end of the process. Possibly because I'm using the free version of the software?
Are there any other ways to export this data into a .sql file so I can import it?
I'm just moving a site from one server to another - it shouldn't be this difficult!
Any help would be really appreciated!
Try the Microsoft SQL Server Database Publishing Wizard. Available at:
http://www.microsoft.com/en-us/download/details.aspx?id=5498
Use the generated .SQL file with these steps:
http://www.123-reg.co.uk/support/answers/Databases/Windows-MSSQL/how-do-i-import-export-a-mssql-database-793/
I don't know if you've managed to resolve this but I have found that the SQL file saved from SSMS is in Unicode format and the 123-Reg website is expecting plain text. This is what's causing the "Could not find stored procedure..." error message.
Instead of saving the file, copy and paste the text from SSMS into Notepad, then save that. The file should then upload correctly into the remote database.

How to edit a Word Document (.docx) stored in a SQL Server Table?

How to edit a Word Document (.docx) stored in a SQL Server Table?
Here is the tentative work flow:
Read BLOB from SQL Table through Ideablade
Write BLOB to disk as .docx
Open .docx using Word
User makes changes
Save .docx using Word
Read .docx into BLOB
Write BLOB back to SQL Table through Ideablade
All sample code is welcomed?
I am sure there are a lot of people doing this already.
Any other ideas on how to simplify this process?
I am using VB.NET, .NET 3.5 SP1, WinForm and SQL Server 2008.
Well, as to the how, here is how to read a blob and write a blob to SQL. Although frankly, unless you have very good reasons such as an existing backup system, you would probably be best served storing the file to the file system and the path and metadata in the database. Either way, abstract it in your BLL, so you can change your mind down the road.
Retrieving and updating the BLOB from the db shouldn't be a problem, you'll find lots of sample code to do that on the net.
A simple approach to your problem would be to create a "temp" or "working" directory somewhere and monitor it with System.IO.FileSystemWatcher (sample code). When the user wants to edit a file, fetch it from the db and store it the directory. Whenever the user saves the file, you'll get a notification from your FileSystemWatcher, so you can save it to the database. Don't forget to empty the directory from time to time.
The method I've seen for this that I think works best is to build this as an add-on for MS Word itself. Examples include the Save to Sharepoint, Save to Moodle, and other similar add-ins.

SSIS 2005 XML Validation Failure Logging

I am working on implementing an SSIS package in SQL Server 2005 which deals with XML files.
Multiple XML files will be read-in from a directory on the file system and data from each XML file will be imported into a database table. The XML to database row works fine and I can iterate over all *.xml files in a specific directory.
I have run into an instance during development when the XML file does not validate against the XSD provided. When this happens the package halts execution. I would like to log the invalid XML filename (and maybe the XML file contents as well) to an error log table in SQL Server and then CONTINUE processing the remaining XML files in the directory.
Has anyone ever done this before? I will also be implementing error logging for the XML data itself so if it can be incorporated into this, I would be open to that idea as well.
Thanks!
I haven't dealt with xml like this in particular, but I can suggest some places to start.
You could place an action in the Event Handlers Tab to handle the error. If you have the the filename and contents in a variable, you can insert that into a table.
I was thinking you could use the error route out of your datasource in a dataflow, but the error probably happens before that.