Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

Help Constructing Update Satement

$
0
0

I am almost a complete newbie to the UPDATE statement. I have a SQL Server 2005 instance with two databases.  I'll call one Hawk and one Eagle.  Hawk has a table called HawkInfo.  DDL Is as follows. 

CREATE TABLE HAWKINFO

(ARNumber NVARCHAR(255) NULL, CSNUMBER NVARCHAR(12) NULL, Customername NVARCHAR (12) NULL )

There are 1215 rows out of some 26,000 that have a NULL CSNUMBER value.  I need to UPDATE the table, supplying the CSNUMBER where it is currently NULL.  There is a table in the EAGLE database called CUSTOMER that has the data I need.  DDL is as follows.

CREATE TABLE CUSTOMER
(ACCTID NVARCHAR (24) NULL,
CSNUMBER NVARCHAR(12) NULL
)

I can write the SELECT statement that retrieves the data that will be used to update the HAWKINFO table. It looks like this:

SELECT H.ARNUMBER
,C.CSNUMBER

FROM HAWKINFO H
INNER JOIN CUSTOMER C ON C.ACCTID = H.ARNUMBER
WHERE H.CSNUMBER IS NULL

How do I put this all together into an update statement that takes the CSNumber from Customer and update the NULL CSNumber values in HAWKINFO?

Lee Markum



Viewing all articles
Browse latest Browse all 23857

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>