update database table from csv file remotely - sql

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.

Related

Having a data upload get "picked up" by SQL Server?

I need to transfer some data over to another location so that it can get "refreshed" in their database system (SQL Server).
I'm a little unfamiliar with this, is SQL server able to refresh its own internal tables based on anything? For instance is it able to recreate/refresh tables based on the contents of .CSV files? Or would I need to move the data over in the form of a small Access database with tables or something similar?
What is the "correct" way to do something like this where you need to refresh the data of another server based on the content you have somewhere else?
Best way would be to use SSIS as Brad suggested.
But if you are not familiar with SSIS packages then you can opt for simple sql server job to upload data from csv files periodically. Please have a look in below links:
Schedule import csv to SQL Server 2014 Express edition
https://answers.laserfiche.com/questions/74591/Auto-Import-csv-into-SQL-Table

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!

Generate Scripts in SQL Server (big files)

I am in process of moving my database from SQL Server 2012 to SQL Server 2008. Since I can't just restore them like if I was moving from 2008 to 2012 I have to use generate scripts for data and schemas.
Problem is I have some HUGE database files. One of the files generate becomes 19gb. There does not seem to be any way to move this file because I think the size itself makes the file corrupt. I cant open the file in the SQL Server Management Studio and even using the .bat script it fails (it just freezes). My other tables I have no problem with but they are much much smaller.
What could fix this would be if there was a way to split the data up in several files like each file is 100mb or whatever, then I could make a script that would execute them all, but is this possible?
If not what do you guys suggest?
I would suggest you create a database with the same name in SQL Server 2008 (and possibly tables) and try to do a replication between the two database with SQL Server 2008 as the subscriber, just once should do
If you have the ability, you could also try creating a linked server entry on the 2008 box that points to the 2012 one. Then, you can use the four part fully qualified name (server.database.schema.table) to SELECT the rows from the 2012 instance and INSERT them into the 2008 instance.

How can I make use of a .db file in SQL server 2008?

I have access to a .db file that I would like to query somehow to pull data from it for my other database. So far I have been unable to do this through an ODBC or SQL server directly. I would think that this is possible but I can't seem to find any ideas how.
.db files are standalone files, so cannot be Opened through SSMS.
Use SQLITE DB BROWSER to work on those files. Thanks :)
.db files are standalone files, which means they don't need server to work, which also means you can't open it with SQL Server 2008.
More more info check THIS LINK
If this is a one time load, the easiest option would be using the SQL Server Import and Export wizard from SSMS. You'll need a Sqlite ODBC driver. The one here should work.
Another option is to create a linked server to SQLite database from SQL Server. See this article for instructions.
Here are a couple of StackOverflow posts on loading data from Sqlite to SQL Server which might be helpful.
Bulk load tables in SQLite db files into SQL Server
Import data from SQLite to SQL Server with SqlBulkCopy class

How Do You Save An Image Out of a SQL Database Into the File System Using only 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.