0

I have a column called Description which has an account number plus text ie 123456 July 2016 Statement. There is also a column that has the account number ie 123456.

In another table I have a reference number ie 100001234. I want to be able to update the Description column to show 100001234 - 123456 July 2016 Statement. The reference number will be different for each account number but there is ONLY 1 reference number per account.

Have tried doing REPLACE but needs 3 arguments or get

Incorrect syntax near 'description'

Code:

 SELECT 
     t.[Referencenumber],
     SET [description] = (REPLACE ([Description], referencenumber + ' - ' + [Description])),
     c.[ClientID], [AccountID]
FROM 
    [Document].[dbo].[DOC.Client] AS c
INNER JOIN
    [Reporting].[dbo].[Tran] AS t ON t.Id = c.accountid

Any suggestions?

1 Answer 1

1

You don't need replace(), but you do need an update. I don't know which table has description:

update ??
    set [description] = referencenumber + ' - ' + [Description]
from [Document].[dbo].[DOC.Client] c inner join
     [Reporting].[dbo].[Tran] t
     on t.Id = c.accountid;
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.