Re: Tidying data
From: Tibor Karaszi (tibor_please.no.email_karaszi_at_hotmail.nomail.com)
Date: 02/22/05
- Next message: Umut Nazlica: "RE: Tidying data"
- Previous message: Gérard Leclercq: "Re: Tidying data"
- In reply to: Griff: "Tidying data"
- Next in thread: Umut Nazlica: "RE: Tidying data"
- Messages sorted by: [ date ] [ thread ]
Date: Tue, 22 Feb 2005 14:32:43 +0100
How about one simple UPDATE statement instead of looping?
UPDATE tbl
SET colname = RTRIM(colname)
200000 rows should be doable in a transaction, but it might be worth splitting this up in several
UPDATE statements, divided by some range in the WHERE clause.
-- Tibor Karaszi, SQL Server MVP http://www.karaszi.com/sqlserver/default.asp http://www.solidqualitylearning.com/ "Griff" <Howling@The.Moon> wrote in message news:uX3k2DOGFHA.3908@TK2MSFTNGP12.phx.gbl... >I have a database table with >20,000 rows and >50 fields, ~45 of which are VARCHARS. > > The data in this database is populated from a fixed-width text file using a process that is > outside of my control. However, this results in many of the fields having leading and/or trailing > spaces. > > I have to find a way to tidy this data up.... > > I adopted the tactic of getting all the table's data back as a disconnected recordset and > iterating through every row & field. If the type is VARCHAR and the value is not NULL, then I > simply update the field's value with the trimmed value. > > Iterating through this is extremely quick. > > However, the UpdateBatch command is EXTREMELY SLOW. So slow that it takes ~ 5 minutes to update ~ > 4000 rows. > > Any alternative tactics I could use? > > Thanks > > Griff >
- Next message: Umut Nazlica: "RE: Tidying data"
- Previous message: Gérard Leclercq: "Re: Tidying data"
- In reply to: Griff: "Tidying data"
- Next in thread: Umut Nazlica: "RE: Tidying data"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|
|