Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to add a column of values

Status
Not open for further replies.

billybobk

Programmer
Oct 14, 2002
130
US
I need to add a column of values to one table (TableA) in the right order. The new column on TableA is 1ColX and is empty. Another table (TableB) has the values for 1ColX in 2Colx, and both tables have a column called CustKey. Each record inserted into 1ColX should then have the same CustKey as when it did in TableB. How is this insert done? Thanks.

Also, in this query:
INSERT INTO Northwind.dbo.Shippers (CompanyName, Phone)
VALUES (N'Snowflake Shipping', N'(503)555-7233')

What does the N' mean???
Thank you lots

--Bill
One may not reach the dawn save by the path of the night
--Kahlil Gibran
 
Bill,
Why would you want to have the same 1Colx values in two tables [in the same db(?)]. You have a relationship CustKey to join those tables, so you have access to them at will. By putting them in both tables, you then have an issue of maintaining their consistency.
BTW, are those the real names of the columns? The N'Snowflake Shipping' tells the db engine to convert the string from ASCII to the international character set. The column defination is probably nvarchar(n).
Code:
Update A
   Set 1Colx=B.2Colx
   from TableA A inner join TableB B on (A.CustKey=B.CustKey)
-Karl
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top