Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
mwdallas
Starting Member
4 Posts |
Posted - 2015-03-19 : 13:04:28
|
I am trying to figure out how to pull only a certain character string.orig string varies in length (Varchar 50)ex: MID - Proposed - Primeex: MID - NotProposed - NotPrimeI want to keep the first 6 characters 'MID - ' as well as up to the 3rd SPACE (not including the space)soex: MID - Proposedex: MID - NotProposedHELP please! |
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2015-03-19 : 13:54:35
|
Here you go:declare @s varchar(50)set @s = 'MID - Proposed - Prime'select LEFT(@s, charindex(' ', @s, 7) - 1)Tara KizerSQL Server MVP since 2007http://weblogs.sqlteam.com/tarad/ |
|
|
|
|
|