Link to home
Start Free TrialLog in
Avatar of goldsmithwilliams
goldsmithwilliamsFlag for United Kingdom of Great Britain and Northern Ireland

asked on

SQL server 2000 - Calculated column - how do i return the first word of a field???

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!

Cheers!
ASKER CERTIFIED SOLUTION
Avatar of solution46
solution46

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of goldsmithwilliams

ASKER

Thanks,

Im new to SQL so am struggling with this, what should I be putting into the formula box by looking at my access code?

Cheers again!
Avatar of solution46
solution46

Er, your best bet is probably to make a view in SQL Server, using the above SQL, and link to that in Access; then use the usual access notation to use your query in your forms.

If you need any more guidance, please give me a few details of your setup and I'll see what I can do.

s46.