August 5, 2009 at 4:06 pm
I have a column with these values 100/200,200/300,300/400 .
I need to add the values and the result will be
A300,A500,A700 with A appended after adding the values. How do I achieve this
Thanks
August 5, 2009 at 4:40 pm
Hi
as long as data length is as provided:
'A' + CAST(CAST(LEFT("yourdata", 3) AS int) + CAST(SUBSTRING("yourdata", 5, 3) AS int) AS char)
regards Graham
________________________________________________________________
you can lead a user to data....but you cannot make them think
and remember....every day is a school day
August 5, 2009 at 5:10 pm
It gives me this error :
Server: Msg 256, Level 16, State 1, Line 5
The data type int is invalid for the substring function. Allowed types are: char/varchar, nchar/nvarchar, and binary/varbinary.
August 5, 2009 at 5:44 pm
try this
'LC' + CAST(CAST(RIGHT (RTRIM(ID), 3) AS INT) + CAST(LEFT (LTRIM(ID), 3) AS INT) AS char)
please follow the advice in the link below ... you will get faster and more detailed and accurate replies
http://www.sqlservercentral.com/articles/Best+Practices/61537/
________________________________________________________________
you can lead a user to data....but you cannot make them think
and remember....every day is a school day
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply