Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Change key field value

Author  Topic 

John Phelan
Starting Member

3 Posts

Posted - 2008-06-19 : 18:18:56
Hi, I'm new to SQL. I have to fix a table as follows:

update recruit.cvs_2 set cv_id = (cv_id + 11000) where change_date <> null

I'm trying to change the value of cv_id e.g. 2 +11000= 11002. cv_id is defined as nvarchar. What am I doing wrong?

John

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2008-06-19 : 18:22:46
set cv_id = CONVERT(nvarchar(50), CONVERT(int, cv_id) + 11000)

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

John Phelan
Starting Member

3 Posts

Posted - 2008-06-19 : 18:28:08
Hi Tara,

I tried this:

update recruit.cvs_2 set cv_id = CONVERT(nvarchar(50), CONVERT(int, cv_id) + 11000) where change_date <> null

and got 'command successful - no rows affected'

John
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2008-06-19 : 18:30:49
where change_date IS NOT NULL

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

John Phelan
Starting Member

3 Posts

Posted - 2008-06-19 : 18:34:54
Hi Tara,

just got it! thanks a lot.

John
Go to Top of Page
   

- Advertisement -