web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :

SQL Script: Get First Email from Semi-colon delimited string

Ian Grieve Profile Picture Ian Grieve 22,784

Microsoft SQL ServerI had a request to produce a SQl view for a client recently which extracted the first email address from the EmailToAddress field in the Address Electronic Funds Transfer Master (SY06000) table linked to a creditor record in Microsoft Dynamics GP. This field generally stores a single email, but sometimes stores multiple email addresses separated with a semi-colon.

The below script will extract the first email address from the field if it is delimited with a semi-colon or the entire content of the field if there is no semi-colon.

/*
Created by Ian Grieve of azurecurve|Ramblings of a Dynamics GP Consultant (http://www.azurecurve.co.uk) This code is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0 Int). */

SELECT
CASE WHEN SUBSTRING(EmailToAddress, 0, CHARINDEX(‘;’, EmailToAddress)) = THEN
EmailToAddress
ELSE
SUBSTRING(EmailToAddress, 0, CHARINDEX(‘;’, EmailToAddress))
END AS Email
FROM
SY01200 Address Electronic Funds Transfer Master (SY06000)

Read original post SQL Script: Get First Email from Semi-colon delimited string at azurecurve|Ramblings of a Dynamics GP Consultant


This was originally posted here.

Comments

*This post is locked for comments