using trim in an update

trying to use trim in an update ... having a problem
update student_info
set rtrim(ltrim(Verify_Name) = FirstName + ' ' + LastName, Diploma_Name = FirstName + ' ' + LastName

 where (Verify_Name = '') and (Diploma_Name = '') and id = 22665
 
select * from student_info where id >= 22665 order by id

Open in new window

HawaiiDragonAsked:
Who is Participating?
 
MikeRenzConnect With a Mentor Commented:
do you want every row with ID > 22665 to be affected?  if so, remove the "and id=22665" from the where statement


update student_info
set Verify_Name = rtrim(ltrim(FirstName + ' ' + LastName)), Diploma_Name = rtrim(ltrim(FirstName + ' ' + LastName))

 where (Verify_Name = '') and (Diploma_Name = '')
select * from student_info where id >= 22665 order by id
0
 
MikeRenzCommented:
update student_info
set Verify_Name = rtrim(ltrim(FirstName + ' ' + LastName, Diploma_Name = FirstName + ' ' + LastName))

 where (Verify_Name = '') and (Diploma_Name = '') and id = 22665
 
select * from student_info where id >= 22665 order by id
0
 
HawaiiDragonAuthor Commented:
@Mike get an Incorrect syntax near '='
0
Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

 
MikeRenzCommented:
oops didn't look closely enough at your code....try this instead.

update student_info
set Verify_Name = rtrim(ltrim(FirstName + ' ' + LastName)), Diploma_Name = rtrim(ltrim(FirstName + ' ' + LastName))

 where (Verify_Name = '') and (Diploma_Name = '') and id = 22665
 
select * from student_info where id >= 22665 order by id
0
 
HawaiiDragonAuthor Commented:
when I run it it states 0 rows effected
0
 
MikeRenzCommented:
this will affect ALL rows if you do it the above way.

are you trying to only set the verify/diploma names for id>22665?  or the entire table?
0
 
HawaiiDragonAuthor Commented:
Yes but each row will have different data in it
0
 
HawaiiDragonAuthor Commented:
Thank you very much that one worked! I forgot a simple method I put in to catch and clean.... Oh the joys of checks LOL
0
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.

All Courses

From novice to tech pro — start learning today.