Thursday, June 18, 2009

Substring syntax in sql

Yesterday I was trying to get a part of a string from a field where the first comma occurs.

For example there is a field named 'Descriptor' which is a combination of "full name, Date of birth, unique number of the record" in that order. I wanted to get the full name using a select statement.

Here is the syntax I used.


select substring(descriptor,1,charindex(',', descriptor)-1) as [fullname]
from contacts

No comments:

Step By Step Guide to resolve SQL server connection issues when connecting from R Studio

Yesterday I tried using a couple of  RevolveScaleR functions -- RxSqlServerData and RxImport.in Rstudio.  These are my learnings as part of ...