473,378 Members | 1,110 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,378 software developers and data experts.

Truncate value



Hi,

I have a field in a table called tblFix, in this table I have a field
called Trailer,.... some of the value of this field is "EXTERN
Terms123456", I want to truncate this field and delete EXTERN Terms
from each one of them and update it with whatever numeric value, so I
want to truncate alpha chars and leave the numeric chars as it is.... I
know very simple UPDATE query but have no clue about this....I am a
novice to SQL... can anyone give some hints where I should start???

Apr 25 '06 #1
6 4925
UPDATE tblTrades SET tblTrades.Trailer = Left( tblTrades.Trailer,13)
WHERE (((tblTrades.Trailer) Like "EXHAUST*") AND
((tblTrades.TradeDateTime)=Date()) AND
((tblTrades.OpposingBroker)="NITE"));
I tried this one but it's not working.... No sure what I am doing wrong
here....

Apr 25 '06 #2
UPDATE tblTrades SET tblTrades.Trailer = Left( tblTrades.Trailer,13)
WHERE (((tblTrades.Trailer) Like "EXHAUST*") AND
((tblTrades.TradeDateTime)=Date()) AND
((tblTrades.OpposingBroker)="NITE"));
I tried this one but it's not working.... No sure what I am doing wrong
here....

Apr 25 '06 #3
When the data is in the "extern" format is it ALWAYS that format?

Is it always "Extern Terms" and then the #?

Ron

Apr 25 '06 #4
No, sometimes. Most of the time data has 6 digit numeric value.

I tried following update query but it's not working:

UPDATE tblFIX SET tblFIX.Trailer = Left( tblFIX.Trailer,13)
WHERE (((tblFIX.Trailer) Like "EXTERN*") AND
((tblFIX.FIXDateTime)=Date()) AND ((tblFIX.Broker)="XXXX"));

Apr 25 '06 #5

anyone would like to give any hint/advice/input??
Hitesh Joshi wrote:
No, sometimes. Most of the time data has 6 digit numeric value.

I tried following update query but it's not working:

UPDATE tblFIX SET tblFIX.Trailer = Left( tblFIX.Trailer,13)
WHERE (((tblFIX.Trailer) Like "EXTERN*") AND
((tblFIX.FIXDateTime)=Date()) AND ((tblFIX.Broker)="XXXX"));


Apr 26 '06 #6
Hitesh Joshi wrote:
anyone would like to give any hint/advice/input??
Hitesh Joshi wrote:
No, sometimes. Most of the time data has 6 digit numeric value.

I tried following update query but it's not working:

UPDATE tblFIX SET tblFIX.Trailer = Left( tblFIX.Trailer,13)
WHERE (((tblFIX.Trailer) Like "EXTERN*") AND
((tblFIX.FIXDateTime)=Date()) AND ((tblFIX.Broker)="XXXX"));


I recommend creating a Public User-Defined Function (UDF) to filter out
the non-digits.

Public Function DigitsOnly(varIn As Variant) As Variant
Dim varTemp As Variant
Dim strChar As String
Dim I As Integer

DigitsOnly = Null
If Len(Nz(varIn, "")) = 0 Then Exit Function
varTemp = Null
For I = 1 To Len(varIn)
strChar = Mid(varIn, I, 1)
If IsNumeric(strChar) Then
varTemp = varTemp & strChar
End If
Next I
DigitsOnly = varTemp
End FunctionstrTemp
End Function
Here's a recursive version:

Public Function DigitsOnly(ByVal varIn As Variant) As Variant
DigitsOnly = Null
If Len(Nz(varIn, "")) = 0 Then Exit Function
If Len(varIn) = 1 Then
If IsNumeric(varIn) Then
DigitsOnly = varIn
Else
DigitsOnly = Null
End If
Else
DigitsOnly = DigitsOnly(Left(varIn, Len(varIn) - 1)) &
DigitsOnly(Right(varIn, 1))
End If
End Function
qryDigitalFilter:
UPDATE tblFIX SET tblFIX.Trailer = DigitsOnly(tblFix.Trailer) ...

Note that the IsNumeric function will only be True for digits when only
one character is used. The functions will replace a ZLS with Null and
leave Nulls alone. Add an extra few lines if you want to preserve
ZLS's. I didn't test to see if preserving ZLS's using the code below
breaks anything or not.

If Len(Nz(varIn, "")) = 0 Then
DigitsOnly = varIn
Exit Function
End If

Hope this helps,

James A. Fortune
CD********@FortuneJames.com

May 1 '06 #7

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

Similar topics

3
by: martin | last post by:
Hi, We have a heavily used production server and a table which logs every hit on a web site. This table has grown large over time and we want to clear it down as efficiently as possible. We would...
3
by: LineVoltageHalogen | last post by:
Greeting All, I have a stored proc that dynamically truncates all the tables in my databases. I use a cursor and some dynamic sql for this: ...... create cursor Loop through sysobjects and...
1
by: New MSSQL DBA | last post by:
I have recently been assigned to take over several MSSQL environments and found some of the existing practice confusing. As most of my previous experiences are on Oracle and Unix platform so would...
1
by: J.J. | last post by:
hi, I have in my report SUBTOTAL=Sum(), then TAX=*0,22 and TOTAL=+ The SUBTOTAL is 6029,80. I sholud get the following values for TAX=1326,556 and for TOTAL=7356,356. I don't need the third...
2
by: rdraider | last post by:
Hi, I am trying to create a script that deletes transaction tables and leaves master data like customer, vendors, inventory items, etc. How can I use TRUNCATE TABLE with an Exists? My problem is...
9
by: Sumanth | last post by:
Are there any implementations of truncate in db2. Is it going to be implemented in the future? Is there an alternate way of doing a truncate of a table that has a high record count without using...
14
by: Sala | last post by:
Hi I want to truncate all data in database ... pls help me how i ll truncate?
10
by: Troels Arvin | last post by:
Hello, Until this date, I believed that DB2 has no TRUNCATE TABLE command. But then I came across...
5
by: Timothy Madden | last post by:
Hello I see there is now why to truncate a file (in C or C++) and that I have to use platform-specific functions for truncating files. Anyone knows why ? I mean C/C++ evolved over many years...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...

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.