2016-09-20 4 views
0

Description이라는 열에 계정 번호와 텍스트 즉 123456 July 2016 Statement이 있습니다. 계정 번호가 123456 인 열도 있습니다.SQL Server 2008의 열에 변수 데이터 추가

다른 표에는 참조 번호가 있습니다 (예 : 1000). Description 열을 1000- 123456 July 2016 Statement으로 업데이트 할 수 있기를 원합니다. 참조 번호는 각 계좌 번호마다 다를 수 있지만 계정 당 하나의 참조 번호 만 있습니다.

는 교체하고 시도했지만 3 개 인자를 필요로하거나 얻을 수 있나요

근처의 구문이 잘못되었습니다 '설명'

코드 :

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 

어떤 제안이?

답변

1

replace()은 필요하지 않지만 update이 필요합니다. 어떤 테이블이 있는지 모르겠습니다 description :

update ?? 
    set [description] = referencenumber + ' - ' + [Description] 
from [Document].[dbo].[DOC.Client] c inner join 
    [Reporting].[dbo].[Tran] t 
    on t.Id = c.accountid;