Solved

Combine SQL update strings

Posted on 2007-11-27
3
925 Views
Last Modified: 2008-02-01
This string works for what I need, but how can I shorten it for multiple column updates in the same row ?

UpdateString = "UPDATE [BCOMerchantTable] set [MerchName]= '" + NewMerchName + "' WHERE MerchID ='" + MerchID + "' UPDATE [BCOMerchantTable] set [MerchAddress]= '" + NewMerchAddress + "' WHERE MerchID = '" + MerchID + '";
0
Comment
Question by:cbrick04
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 11

Accepted Solution

by:
deroby earned 500 total points
ID: 20356359
UpdateString = "UPDATE [BCOMerchantTable] set [MerchName]= '" + NewMerchName + "', [MerchAddress]= '" + NewMerchAddress + "' WHERE MerchID = '" + MerchID + '";
0
 
LVL 75

Expert Comment

by:Aneesh Retnakaran
ID: 20356360
UpdateString = "UPDATE [BCOMerchantTable] set [MerchName]= '" + NewMerchName +
 + "' , [MerchAddress]= '" + NewMerchAddress + "' WHERE MerchID = '" + MerchID + '";
0
 
LVL 11

Expert Comment

by:deroby
ID: 20356364
In other words : you can simply list all the fields to be updated one after the other, separated by comma's

UPDATE <sometable> SET field1 = 'value1', field2 = 'value2', field3 ='value3', etc...  WHERE <something is true>
0

Featured Post

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
In the first part of this tutorial we will cover the prerequisites for installing SQL Server vNext on Linux.
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question