I thought the problem was licked. I've got two tables from an external source via ODBC drivers, right?
Table 1: Area has "AkeaKey" and "AreaID" -- AreaKey is a Primary Key
Table 2: Equipment has "AreaKey" and "EquipmentID" -- AreaKey is a Primary Key
AreaID is a text field of 4 characters...of which I need only those records with numeric values, and I need only the first 2 characters (no spaces afterwards).
EquipmentID is a text field of 10 characters...I will use all 10 characters (numbers).
I need to "merge"? the data into one FIELD, such that the areaID digits preceed the equipmentID digits for a total of 12 characters, with an output format of 1234-1234-1234.
Examples from the two tables are below:
AreaKey AreaID AreaKey EquiptKey EquipmentID
-2832 SAWS -2832 -2833 1800BD2RPM
-2832 SAWS -2832 -2863 1200BD2RPM
-31919 30 -31919 -32100 7501130700
-31919 30 -31919 -32160 7501171000
I'd like to run this query / queries such that those records with alpha characters in the AreaID are not used in the final output (they are information provided by the software vendor for troubleshooting). So far I'm using 2 make table queries, so that the final product (table 4)can be easily acessed via excel.
The problem I have is this:
one - when I run the first solution provided as a solo query (merging the two fields, complete with spaces), my records jump from 414 records to over 10,000 records!!!
two - when I run the final solution provided as a solo query (merging the two fields, with the last two characters trimmed off), causes my new 12 character equipment ID (with hyphens) to be changed...here is a sample:
3075-3075-3075
3075-3075-3075
3165-3165-3165
3165-3165-3165
You can see that the numbers are identical in groups? why does it do this?
Here's the query as I'm using it:
SELECT Mid(RTrim(LTrim(CStr(AreaID)))+CStr(EquipmentID),1,4)+"-"+Mid(RTrim(LTrim(CStr(AreaID)))+CStr(EquipmentID),1,4)+"-"+Mid(RTrim(LTrim(CStr(AreaID)))+CStr(EquipmentID),1,4) AS SplitID, RBM_Eqpt.Description, RBM_Eqpt.LastTrend, RBM_Eqpt.EquipAlarmStatusCode INTO MP2_Vib
FROM RBM_Eqpt;
Any help you can give me is greatly appreciated...otherwise, I'm gonna have to read this "Complete Reference SQL" book on my desk.
Ken