August 12, 2002 at 4:43 am
Is there the same usage in SQL 7.0 for INSTR to find a string within a string and return the integer??
ie LEFT (STKCODE, INSTR(1, STKCODE, "-")-1) as StrCount
Thanks
Scott
Edited by - burthold on 09/17/2002 09:02:35 AM
August 12, 2002 at 7:02 am
CharIndex or PatIndex should do it.
Andy
August 12, 2002 at 7:38 am
Thanks Andy....
Just what I was looking for..
Cheers
Scott
September 17, 2002 at 8:59 am
I am trying to find the position of a comma inside a var char field. INSTR does not seem to be a function in SQL Server 7.0, so what do I use. I tried charindex(field, ',') and it always returns zero.
Stanton
September 17, 2002 at 9:11 am
I think you have the charindex function backwards. It should read "charindex(',',field). Here is a stupid example that might help.
declare @STR varchar(100)
set @STR = 'Question: Where is the, comma in this sentence?'
select 'Answer: This comma is at offset ' +
rtrim(cast(charindex(',',@str) as char)) +
' in the @STR variable. '
Gregory Larsen, DBA
If you looking for SQL Server Examples check out my website at http://www.geocities.com/sqlserverexamples
Gregory A. Larsen, MVP
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply