July 18, 2012 at 5:04 am
Hi
I'm sure someone will know an answer to this.
I need to insert a decimal point (.) as the forth character of an exising field
example
A1234 will become A12.34
B98765 will become B98.765
Many Thanks in advance
July 18, 2012 at 5:11 am
Take a look at the substring function
/*
A1234 will become A12.34
B98765 will become B98.765
*/
DECLARE @String1 VARCHAR(10)
DECLARE @String2 VARCHAR(10)
SELECT @String1 = 'A1234',
@String2 = 'B98765'
SELECT SUBSTRING(@String1,1,3) + '.' + SUBSTRING(@String1,4,LEN(@String1)-3),
SUBSTRING(@String2,1,3) + '.' + SUBSTRING(@String2,4,LEN(@String2)-3)
July 18, 2012 at 5:12 am
Hi,
You can use this Query to add an character in between the value of an existing field
Select STUFF(ColumnName,4,0,'.') from TableName
Hope this helps.. 😉
Thanks
Kivan.G
July 18, 2012 at 6:37 am
many thanks, works a treat.
P
July 19, 2012 at 6:17 am
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply