November 23, 2010 at 7:42 pm
I have a database with several tables in it. I need to update one table (Table A) with data from Table B.
Table A structure
id_number nvarchar 50 NULL
acctno nvarchar 50 NULL
name nvarchar 50 NULL
address1 nvarchar 50 NULL
address2 nvarchar 50 NULL
altname1 nvarchar 50 NULL
allname2 nvarchar 50 NULL
Table B structure
acctno nvarchar 50 NULL
altname nvarchar 50 NULL
Data in Table B
12345a Joe1
12345a
November 23, 2010 at 8:09 pm
please disregard this post as i inadvertently hit submit.
terry
November 23, 2010 at 8:10 pm
Update TableA.name column with values from TableB.altname ?
UPDATE A
SET A.name = B.altname
FROM TableA A
JOIN TableB B
ON A.acctno = B.acctno
Wont this do for you?
November 23, 2010 at 8:11 pm
terry.davis (11/23/2010)
please disregard this post as i inadvertently hit submit.terry
:-D:-P
November 23, 2010 at 8:27 pm
thanks for the reply but I need to update the altname1 and altname2 fields, not the name field, with the two entries in TableB for the acctno.
thanks
terry
November 23, 2010 at 9:15 pm
Duplicate post - please post all replies to this thread. A solution has already been provided over there.
Wayne
Microsoft Certified Master: SQL Server 2008
Author - SQL Server T-SQL Recipes
Viewing 6 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply