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
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Concatenation

Author  Topic 

victord
Yak Posting Veteran

64 Posts

Posted - 2003-01-22 : 09:04:55
Hi folks,
I am trying to concatenate data in a column of a table with zeroes,'000'where ever the figures are 2 or more e.g '45' becomes '45000. But i am getting datatype errors. The datatype of the column is int , but then has data of more than 6 figures e.g '100000'.

Below is an example scipt:

update stahemog2
set module_mark = '__' + '000'
WHERE (module_mark <> '0')
AND (module_mark LIKE '__')

But i am getting the following error:

Server: Msg 245, Level 16, State 1, Line 1
Syntax error converting the varchar value '__000' to a column of data type int.

What am i doing wrong here
Thanks
Vic



robvolk
Most Valuable Yak

15732 Posts

Posted - 2003-01-22 : 09:11:28
You can't concatenate a numeric column. It can only be manipulated through arithmetic functions. Basically you want to multiply the column by 1000, if its value is greater than or equal to 10:

UPDATE stahemog2
SET module_mark = module_mark * 1000
WHERE module_mark >= 10


Go to Top of Page

victord
Yak Posting Veteran

64 Posts

Posted - 2003-01-22 : 09:38:23
[quote]
You can't concatenate a numeric column. It can only be manipulated through arithmetic functions. Basically you want to multiply the column by 1000, if its value is greater than or equal to 10:

UPDATE stahemog2
SET module_mark = module_mark * 1000
WHERE module_mark >= 10



[/Thanks for your help again that was spot on.]

Go to Top of Page
   

- Advertisement -