Syntax error near coalesce

Thanks for help.
cmd.CommandText = "update dbo.User_Info SET COALESCE(@FirstName, FirstName),COALESCE(@LastName,LastName),COALESCE(@Degree,Degree),COALESCE(@Organization,Organization),COALESCE(@Phone,Phone),COALESCE(@Ext,Ext) where UserName =@username";
            cmd.Parameters.Add("FirstName", SqlDbType.VarChar).Value = TextFirstName.Text;
            cmd.Parameters.Add("LastName", SqlDbType.VarChar).Value = TextLastName.Text;
            cmd.Parameters.Add("Degree", SqlDbType.VarChar).Value = TextDegree.Text;
            cmd.Parameters.Add("Organization", SqlDbType.VarChar).Value = TextOrg.Text;
            cmd.Parameters.Add("Phone", SqlDbType.VarChar).Value = TextPhone.Text;
            cmd.Parameters.Add("Ext", SqlDbType.VarChar).Value = TextExt.Text; 

Open in new window

zhshqzycAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

tim_csCommented:
You don't have the value that you are trying to set in your query.


update dbo.User_Info SET
   FirstName = COALESCE(@FirstName, FirstName),
   LastName = COALESCE(@LastName,LastName),
   Degree = COALESCE(@Degree,Degree),
   Organization = COALESCE(@Organization,Organization),
   Phone = COALESCE(@Phone,Phone),
   Ext = COALESCE(@Ext,Ext)
where UserName =@username
0
Jim HornMicrosoft SQL Server Developer, Architect, and AuthorCommented:
update dbo.User_Info  SET
  {You need a column name here to set to } = COALESCE(@FirstName, FirstName),
  {You need another column name here to set to } = COALESCE(@LastName,LastName),
   etc.
0
Guy Hengel [angelIII / a3]Billing EngineerCommented:
update yourtable set somefield = coalesce(...)

you are missing to indicate the field(s) you want to update  ...
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server 2008

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.