The Way to Programming
The Way to Programming
I need to download a csv file to sql to construct after a graph with visual studio.
I have all of this running but with integration services, but i want to do the same without the integration services because integration services not exist in sql express.
if you want to construct SQL statements from your CSV file, you can simply open it with a Spreadsheet program like Excel and insert the SQL statements between the data columns. A bit tedious, but it works Smile
There might be tools to import CSV data if the columns match the tables in your database, but I’ve not familiar with any.
You could use awk on a Linux machine, or install one of the free versions available for Windows, and then run a script like this:
BEGIN { print "INSERT INTO [mydb].[mytable]" print " ([fieldname1], [fieldname2], [fieldname3])" print " VALUES" } { print " (" $0 ")," }
using the command
awk -f myfile.awk myfile.csv
Of course this assumes that the CSV fields map one-to-one with your columns. If they don’t, you can use multiple awk scripts to extract the individual fields and generate multiple SQL scripts.
If you’re on windows look up using a Schema.ini to label the field names and type. Then all you have to do is something like SELECT * INTO tbl FROM [File Path] IN [Name of File] (I can’t remember the exact syntax now). You’ll end up with a table that has been imported nicely from a CSV.
If you need more info PM me and i’ll reply when I’m at work – I’m doing this kind of thing there at the minute. It’s a very fast and easy way of getting the data into a table.
Sign in to your account