I'm doing an active directory extract using t-sql and need to manipulate the mobile column to prefix it with the country code and drop the first character. Prefixing the country code is simple using '999' + mobile
But I also need to drop the first char as this is not required when calling from out of the country.
So if the underlying data is '0123123123' I need the result to be '999123123123' I need this to handle the possibility of the column being NULL, probably best to trim any leading spaces while we're at it. This select is wrapped around an OpenQuery so the string manipulation will need to happen as part of the outer select....
SELECT top 901, '999' + mobile as 'NZ mobile' FROM OpenQuery (
'SELECT mail, mobile, telephoneNumber, title, sn, givenName, SAMAccountName FROM ''LDAP://xxxxxxx'' WHERE objectClass = ''user'' AND givenName<=''z'' AND title>=''a''') AS tblADS