473,405 Members | 2,300 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

update tables from a csv file?

Hello and thank you for your time. I have never worked with sql
server and currently have a project updating the database.

I have a CSV file as follows:
id
keywords (this field contains commas within)
date

I have a sql server table as follows with only the id populated.
id
keywords
date

How do I update the sql server fields from the CSV file? I'm assuming
I would use an UPDATE statement. What SQL server utility would I use
(I'm very new at this, please be basic)?

Thank you once again,
Sunshine
Jul 20 '05 #1
3 18839
su************@yahoo.com (Sunshine) wrote in message news:<7b**************************@posting.google. com>...
Hello and thank you for your time. I have never worked with sql
server and currently have a project updating the database.

I have a CSV file as follows:
id
keywords (this field contains commas within)
date

I have a sql server table as follows with only the id populated.
id
keywords
date

How do I update the sql server fields from the CSV file? I'm assuming
I would use an UPDATE statement. What SQL server utility would I use
(I'm very new at this, please be basic)?

Thank you once again,
Sunshine


One way is to create a load table with the same structure as the
destination table, and use DTS (Import and Export Data) to load the
CSV file into it. When you've done that, then you can use a query like
this:

update dbo.MyTable
set keywords = l.keyords, date = l.date
from dbo.MyTable t
join dbo.MyTable_Load l
on t.id = l.id

You could also look at bcp.exe or BULK INSERT to load the CSV data.

Simon
Jul 20 '05 #2
Please post your table structure like this:

CREATE TABLE TableName
(
id int identity not null primary key,
keywords varchar(100),
[date] as datetime -- smalldatetime?
)

and a sample of your data like this:

1
KEYWORD,KEYWORD,KEYWORD,...
05/28/04
2
KEYWORD,KEYWORD,KEYWORD,...
05/28/04

Otherwise, we're forced to make assumptions that may not be correct.

Thanks.
"Sunshine" <su************@yahoo.com> wrote in message
news:7b**************************@posting.google.c om...
Hello and thank you for your time. I have never worked with sql
server and currently have a project updating the database.

I have a CSV file as follows:
id
keywords (this field contains commas within)
date

I have a sql server table as follows with only the id populated.
id
keywords
date

How do I update the sql server fields from the CSV file? I'm assuming
I would use an UPDATE statement. What SQL server utility would I use
(I'm very new at this, please be basic)?

Thank you once again,
Sunshine

Jul 20 '05 #3
Solution 1:
~~~~~~~~~~~
Use DTS and transfer the contents from the CSV file to a table. Join
the original table in the SQL Server and the table created using DTS
and update the table in sql server

Solution 2:
~~~~~~~~~~~
Create linked server in SQL Server for the CSV file. Join and update
the table in sql server.

Hope this helps
Ramesh

su************@yahoo.com (Sunshine) wrote in message news:<7b**************************@posting.google. com>...
Hello and thank you for your time. I have never worked with sql
server and currently have a project updating the database.

I have a CSV file as follows:
id
keywords (this field contains commas within)
date

I have a sql server table as follows with only the id populated.
id
keywords
date

How do I update the sql server fields from the CSV file? I'm assuming
I would use an UPDATE statement. What SQL server utility would I use
(I'm very new at this, please be basic)?

Thank you once again,
Sunshine

Jul 20 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Pesko S | last post by:
Hi, Could anybody just point me in a direction where I can find information on how the heck I can update a database with relational data from an XML file. I use stored procedures to insert...
2
by: nek | last post by:
Seasons greetings, Platform is W2K SP4, DB2 V8.1 FP2. A few days ago I posted the question to globally 'update db cfg' for all servers which could be done via a script thanks to Ian and PM's...
4
by: Jozef | last post by:
Hello, I'm trying to check for and add a field to a table to a back end database through code. The problem I've been faced with is changing permissions, because I have to use administer...
2
by: siaj | last post by:
Hi.. I m just trying to learn using XML file as a datastore. I am reading a dataset from a XML file and then trying to update the XML file with some changes in the dataset. My code is as...
12
by: facicad | last post by:
Look my prog. I have combobox where is have all tables names of access file. The user select one table and the content is show in datagrid. The user can add, erase or modify some record or row. ...
2
by: Subhashini | last post by:
Hi friends, i have one doubt, that how can we update a file without using a temporary file in C. i need to do it in my program. If there is any way to do so then please let me know the procedure....
0
by: Patty05 | last post by:
Can someone help me please. I can not figure out what is wrong. I get the error: "An unhandled exception of type 'System.Data.OleDb.OleDbException' occured in system.data.dll. I am simply trying...
0
by: =?Utf-8?B?TWF0dA==?= | last post by:
Hello, Can someone please advise. I have been unable to install any security, wmp and explorer updates for some time. Looking at the logs there seems to be trouble with the location of the...
1
by: SKODA | last post by:
Hi, Could someone help me in knowing how to update tables in MS Access with data available on a website? I mean the functionality similar to refresh available in MS EXCEL where the data is...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.