Groups | Blog | Home
all groups > sql server programming > august 2003 >

sql server programming : help me with repace


chughes NO[at]SPAM playlegal.com
8/7/2003 10:55:46 PM
I am trying to replace any text after and including a minus from a
column can someone suggest an easy way. The idea is that I may have
one column that might have ch-120 or gh-130 how do i go about gettinbg
SriSamp
8/8/2003 11:41:01 AM
Here is one way:
DECLARE @strString VARCHAR(100)
BEGIN
SET @strString = 'ch-120'

SELECT @strString = LEFT(@strString, (CHARINDEX('-', @strString) - 1))
SELECT @strString
END
The output of this will be "ch".
--
HTH,
SriSamp
Please reply to the whole group only!
http://www32.brinkster.com/srisamp

[quoted text, click to view]

AddThis Social Bookmark Button