how to grab characters that preeced a delimeter in a filed?

Posted on 2011-05-10
Medium Priority
Last Modified: 2012-05-11
how to grab characters that preeced a delimeter in a field?  I would like to grab all teh characters to the left of the first delimeter in my field.  For example if the text in the field is 02/20/2010 then return 02, if it is 2/20/2010 then return 2, it the text is 002/20/2011 then 002
Question by:kat50
1 Comment
LVL 39

Accepted Solution

Pratima Pharande earned 2000 total points
ID: 35727431
SELECT LEFT('02/20/2010',CHARINDEX('/', '02/20/2010')-1) )

with column name

SELECT LEFT(col_name,CHARINDEX('/', col_name)-1) )

Featured Post

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A Stored Procedure in Microsoft SQL Server is a powerful feature that it can be used to execute the Data Manipulation Language (DML) or Data Definition Language (DDL). Depending on business requirements, a single Stored Procedure can return differe…
It is possible to export the data of a SQL Table in SSMS and generate INSERT statements. It's neatly tucked away in the generate scripts option of a database.
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Via a live example, show how to setup several different housekeeping processes for a SQL Server.
Suggested Courses

862 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question