Feb 27 2024 11:54 AM
I’m trying to update a field in a table based on the value in another field in the same table.
example
table = customers
field 1 = customer
field 2 = code
I have three records in the customers table - field ref = customer
1. Smith and sons
2. Smiths industries
3. Smiths Lmited
i want to update customers table setting the code field to have the first three letters of the customer field then serial reference
so the three records containing the code field would read
1. SMI001
2. SMI002
3. SMI003
If anyone could help me with the correct mssql syntax then I would appreciate it.
best regards Darrell
Feb 27 2024 10:31 PM
@F1-bc , use the LEFT (Transact-SQL) - SQL Server | Microsoft Learn function to get the first 3 letters.
For a more details answer, post more details: Please post table design as DDL, some sample data as DML statement and the expected result.
Feb 28 2024 12:22 AM
@olafhelper Thanks appreciate you replying. I'll give this a try as well.