Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi,
I need to trim some field values in a product table. All products are having their name starting with 'PR'.
Example (PRODUCT TABLE): PRFOOD, PRDRINKS, PDFLAVORS etc
I need to remove 'PR' from front of all above names while loading the script.
Regards,
H
Hiya,
Another option could be:
Load
ProductID
, SubField(ProductName,'PR',2) AS NewProductName;
SQL SELECT
Product ID
, ProductName
FROM ProductsTable;
Hope this helps.
Hi,
You simply need to alias the field names using the AS statement, eg:
LOAD
PRFOOD as Food,
PRDRINKS as Drinks,
PRFLAVORS as Flavors,
When I have many many fields that I have to do this sort of thing for I tend to paste the field list into Excel then in an adjoining cell have an expression to build the load script for me, eg:
=CONCATENATE(" ", A1, " AS [", PROPER(MID(A1, 3, 99)), "],")
This can then be copied down for each field in Excel, the column containing all the values can then be copied and pasted directly into your load script.
Hope that helps,
Steve
Hi Steve,
My table looks like this:
PRODUCT TABLE has following values where I need to remove PR
PRFOOD
PRDRINKS
PRFLAVORS
Thanks,
H
Hi H,
Maybe I'm got you wrong, but let try:
[Product]:
Load
ProductID,
ProductName,
Mid(ProductName,3,Len(ProductName)) AS NewProductName;
Select ProductID,ProductName From PRODUCT;
Regards,
Sokkorn
Are you taking about Field Names or Field Values?
If you want rename the Field names, just follow the Steve procedure. If you want change the field values, Please use RIGHT function: RIGHT(FIELNAME, LEN(FIELDNAME)-2) AS FIELDNAME
Hiya,
Another option could be:
Load
ProductID
, SubField(ProductName,'PR',2) AS NewProductName;
SQL SELECT
Product ID
, ProductName
FROM ProductsTable;
Hope this helps.
Hi,
Sorry, I thought those values were column names. Sokkorn's suggestion is
fine.
Mid(PRODUCT, 3, 99) as Product,
Steve