Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2005-04-21 : 08:07:21
|
| Winterhawk writes "Sorry if this is simple. I am new to development DBA activities. I have a table with 14 columns. The tenth column is called DRCR. It has a single letter designation for debit or credit. I get this as a datafile extract from an old mainframe. The file is usually about 1.5 to 2.5 million rows each week. The business logic package calculates numbers based on the debit or credit sign in this tenth column. My issue is the package changed and now this natural account sign (D or C) must be reversed in the data load file, i.e., if "D" then make it a "C" and if "C" then make it a "D." It looks like a some kind of search and replace cursor would do it. Is there a more efficient way to reverse all the D's or C's in this column before my dataload? Thanks and sorry if such a simple one is an affront to your intelligence." |
|
|
mwjdavidson
Aged Yak Warrior
735 Posts |
Posted - 2005-04-21 : 11:20:39
|
| You definitely don't want to use a cursor, especially on those kind of volumes! Do the update as a set using a case statement:UPDATE mytableSET mycolumn = CASE mycolumn WHEN 'C' THEN 'D' WHEN 'D' THEN 'C' ENDI imagine you'll want to add a where clause to this statement to constrain the update.Are you Bulk Inserting the file? |
 |
|
|
|
|
|