Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Is it possible to grab a ANSII file and do a update via TSQL

Status
Not open for further replies.

smileydba

Programmer
Jun 21, 2005
15
0
0
US
Is it possible in TSQL to be able to grab a file on the server and do a update to a particular table. Say, for example, there is a ANSII file on the desktop, and I need the TSQL to grab that file and update a table. Is there a query that can do that (possible SP or trigger)


Rob W.
 
Does the file to be used contain just one value/string per line/record? What I mean here is ... are there more than one values on a line ie ...

XYZ, 123, DDD
ABC, 654, OOO

Or is it just a single value per line ...

ABCDE
FGHUK
SJIEK


Thanks

J. Kusch
 
There is more then one value, such as,

xyz, 123, abc, 123

rst, 456, def, 789

So lets say, there is a file on the desktop called update1.sql, in this ANSII file is data to update a table called items

Server Desktop --> update1.sql --> Query Analyzer(TSQL)-->Table(items)

I know I can do this via DTS, but I want to do it via TSQL because it offers more control.

Rob W.

Rob W.
 
if the file on is structured in a way were a single row to update is represented in a line within the file then you can bcp in the file to a stage table then run the update from the stage table.

Shoot Me! Shoot Me NOW!!!
- Daffy Duck
 
You can use the bulk insert command from within T/SQL to import the file. Lookup bulk insert in Books OnLine. It's got the syntax, and a decent example.

Denny
MCSA (2003) / MCDBA (SQL 2000)

--Anything is possible. All it takes is a little research. (Me)

[noevil]
(Not quite so old any more.)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top