teogos
asked on
INSERT INTO SQL QUERY FIELD
Data is coming from the SLQ database like this B1234DPRF . I want to modify this on a query
to show me like B-1234-DPRF ,any ideas how to do this so. after the first character insert a - then after the fifth character insert another -
to show me like B-1234-DPRF ,any ideas how to do this so. after the first character insert a - then after the fifth character insert another -
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
p.s. If always 4 characters after the last '-' then just substitute 4 for len(field).
You can also use left and right, I believe -
select left(field,4) +'-' substring(field(2,4) + '-' right(field,4)
You can also use left and right, I believe -
select left(field,4) +'-' substring(field(2,4) + '-' right(field,4)
Tony303, sorry I never saw your post before I submitted.
@awking.
Yeah, it is rare that I get a solution in first!!
Normally, while I am working the question out there are bigger brains on the job and get in before me!!!
Cheers now.
T :-)
Yeah, it is rare that I get a solution in first!!
Normally, while I am working the question out there are bigger brains on the job and get in before me!!!
Cheers now.
T :-)
SET @data = 'B1234DPRF'
SELECT @Data
SELECT left(@data,1) + '-' + Substring(@data,2,4) + '-' + SUBSTRING(@Data,6,4) AS Done
Open in new window