all groups > sql server programming > december 2004 >
You're in the

sql server programming

group:

update multiple values



Re: update multiple values Andrew J. Kelly
12/19/2004 1:59:06 PM
sql server programming: No, you either have to use two sub-selects or join the tables.

--
Andrew J. Kelly SQL MVP


[quoted text, click to view]

Re: update multiple values Jay Nathan
12/19/2004 2:02:29 PM
What is the goal of your query, and perhaps it'll be easier to answer you
question? Are you trying to update these two values in the Customer record
with an ID of 'ALFKI'? It is possible to use an UPDATE FROM statement
similar to the on below:

UPDATE Customers
SET Customers.CompanyName = c2.CompanyName, Customers.ContactName =
c2.ContactName
FROM Customers c2 INNER JOIN Customers ON c2.CustomerID =
Customers.CustomerID
WHERE c2.CustomerID = 'ALFKI'

You would typically be getting values from another table...

Jay Nathan
http://www.jaynathan.com/blog






[quoted text, click to view]

Re: update multiple values John Bell
12/19/2004 8:45:04 PM
Hi

If you only want to set all companynames to 'Name' and ContactNames to
'Sora' when the companyID is 'ALKFI' then there is no need for the subselect

UPDATE Customers
SET CompanyName = 'Name ',
ContactName = 'Sora'
WHERE CustomerID = 'ALFKI'

John

[quoted text, click to view]

update multiple values Emre Guldogan
12/19/2004 8:46:45 PM
UPDATE Customers
SET
( CompanyName , ContactName ) =
(SELECT 'Name ', 'Sora'
FROM Customers )
WHERE CustomerID='ALFKI'

it does not work on mssql ,
is there an equivalance for mssql ?

thanks

Re: update multiple values --CELKO--
12/20/2004 6:14:12 AM
If it will make you feel better you have correctly guess SQL-99 syntax;
you just own a product that is a few years behind in implementing it
:)

UPDATE Customers
SET company_name = 'Name '
contact_name = 'Sora'
WHERE customer-id = 'ALFKI';
AddThis Social Bookmark Button