SQL server 2000 - Calculated column - how do i return the first word of a field???
Posted on 2004-09-20
Hi I am trying to create a column in a table that always returns the first part of another field. I need to strip a postcode down to the first part ie "L35 6YT" would be "L35" the first part is between 2 and 4 charactors long so I cant use a simple trimming function. I have done it in access using this code
Left([IntroducerPostcode],InStr([IntroducerPostcode] & " "," ")-1)
but SQL server 2000 doesnt read the commands??
any ideas? Im doing it so I can compare the postcode in a transactions table to the postcode in another table, but the postcodes stored in the other table are only the first part and not the full code that is stored in the transactions table. Im thinking maybe I can set a join up between the two fields in a query once I can get only the first part to return in the tranactions table.
Hope that makes sense! There may be an easier way to do it in which case let me know!